Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dogshell] Enforce the default 'normal' event priority client side #511

Merged
merged 1 commit into from
Jan 10, 2020

Conversation

brouberol
Copy link
Contributor

@brouberol brouberol commented Jan 10, 2020

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue, or add one feature, at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

Enforce the default event priority value to normal when submitting an event via the API.

Description of the Change

The CLI help output stats that the default priority value used when
posting an event with dog event post is normal. That value isn't
enforced on the client side, and it seems leaving it to None has an
unexpected side effect: the API returns an HTTP 200 response along with
an link to the indexed event, which always returns an HTTP 404.

Example:

$ dog --raw event post --alert_type 'info' --no_host 'test by balthazar' 'checking for any pebcak' | jq .
{
  "status": "ok",
  "event": {
    "id": XXXX,
    "title": "test by balthazar",
    "text": "checking for any pebcak",
    "date_happened": 1578645516,
    "handle": null,
    "priority": null,
    "related_event_id": null,
    "tags": [],
    "url": "https://app.datadoghq.com/event/event?id=1234"
  }
}

That event url always returns an HTTP 404 when opened. We can see
"priority": null in the response payload.

If we however explicitly set the --priority flag to normal in the
command-line, we can see "priority": "normal" in the JSON output:

$ dog --raw event post --priority normal --alert_type 'info' --no_host 'test by balthazar' 'checking for any pebcak' | jq .
{
  "status": "ok",
  "event": {
    "id": YYYYY,
    "title": "test by balthazar",
    "text": "checking for any pebcak",
    "date_happened": 1578645659,
    "handle": null,
    "priority": "normal",
    "related_event_id": null,
    "tags": [],
    "url": "https://app.datadoghq.com/event/event?id=ABCD"
  }
}

Visiting the event URL now returns an HTTP 200, and I can find the event
by searching in the event stream.

Additional API validation will of course have to be added server-side
but this is at least a start.

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

The CLI help output stats that the default `priority` value used when
posting an event with `dog event post` is `normal`. That value isn't
enforced on the client side, and it seems leaving it to `None` has an
unexpected side effect: the API returns an HTTP 200 response along with
an link to the indexed event, which always returns an HTTP 404.

Example:

```console

$ dog --raw event post --alert_type 'info' --no_host 'test by balthazar' 'checking for any pebcak' | jq .
{
  "status": "ok",
  "event": {
    "id": XXXX,
    "title": "test by balthazar",
    "text": "checking for any pebcak",
    "date_happened": 1578645516,
    "handle": null,
    "priority": null,
    "related_event_id": null,
    "tags": [],
    "url": "https://app.datadoghq.com/event/event?id=1234"
  }
}
```

That event url always returns an HTTP 404 when opened. We can see
`"priority": null` in the response payload.

If we however explicitly set the `--priority` flag to `normal` in the
command-line, we can see `"priority": "normal"` in the JSON output:

```console
$ dog --raw event post --priority normal --alert_type 'info' --no_host 'test by balthazar' 'checking for any pebcak' | jq .
{
  "status": "ok",
  "event": {
    "id": YYYYY,
    "title": "test by balthazar",
    "text": "checking for any pebcak",
    "date_happened": 1578645659,
    "handle": null,
    "priority": "normal",
    "related_event_id": null,
    "tags": [],
    "url": "https://app.datadoghq.com/event/event?id=ABCD"
  }
}
```

Visiting the event URL now returns an HTTP 200, and I can find the event
by searching in the event stream.

Additional API validation will of course have to be added server-side
but this is at least a start.
@brouberol brouberol added the bug label Jan 10, 2020
@brouberol brouberol requested a review from a team as a code owner January 10, 2020 10:01
@gzussa
Copy link
Contributor

gzussa commented Jan 10, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@gzussa gzussa merged commit 0e0efca into master Jan 10, 2020
@gzussa gzussa deleted the brouberol/force-event-priority-at-post branch January 10, 2020 11:58
@zippolyte zippolyte added the changelog/Fixed Fixed features results into a bug fix version bump label Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Fixed Fixed features results into a bug fix version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants