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

Alertmanager endpoints shouldn't wrap errors with prometheusAPIError() #123

Open
simonpasquier opened this issue Aug 4, 2022 · 0 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@simonpasquier
Copy link
Contributor

simonpasquier commented Aug 4, 2022

When returning something different than 2xx, the Alertmanager API returns a plain text body. E.g.

$ curl -sv  -H "Content-Type: application/json" http://localhost:9093/api/v2/silences -d '{"comment":"", "createdBy":"", "endsAt":"","matchers":[{"isRegex": false, "name":"foo","value":"bar"}],"startsAt":""}'
*   Trying 127.0.0.1:9093...
* Connected to localhost (127.0.0.1) port 9093 (#0)
> POST /api/v2/silences HTTP/1.1
> Host: localhost:9093
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 117
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Vary: Origin
< Vary: Accept-Encoding
< Date: Thu, 04 Aug 2022 09:41:13 GMT
< Content-Length: 63
< 
"Failed to create silence: start time must be before end time"
* Connection #0 to host localhost left intact

But an error returned by prom-label-proxy would format the error message as a Prometheus API response.

Note that when a validation error happens at the OpenAPI level, the format of the response is different (e.g. it's valid JSON):

 curl -sv  -H "Content-Type: application/json" http://localhost:9093/api/v2/silences -d '{"comment":"", "createdBy":"", "endsAt":"","matchers":[{"isRegex": false, "name":"foo","value":"bar"}]}'
*   Trying 127.0.0.1:9093...
* Connected to localhost (127.0.0.1) port 9093 (#0)
> POST /api/v2/silences HTTP/1.1
> Host: localhost:9093
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 103
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 422 Unprocessable Entity
< Content-Type: application/json
< Vary: Origin
< Vary: Accept-Encoding
< Date: Thu, 04 Aug 2022 09:42:04 GMT
< Content-Length: 53
< 
* Connection #0 to host localhost left intact
{"code":602,"message":"startsAt in body is required"}
@simonpasquier simonpasquier added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jun 15, 2023
@simonpasquier simonpasquier pinned this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

No branches or pull requests

1 participant