Skip to content

Commit aaf9490

Browse files
authored
API: Allow the Silences API to use their own 400 response (#3610)
There's no change to the logic here - it just stroke me as odd that we were reusing the response from alerting groups in the silences call when it's pretty simple to add a new one in the API description. This is more accurate as well, as this will be used to power the documentation. Signed-off-by: gotjosh <[email protected]>
1 parent ca5089d commit aaf9490

File tree

5 files changed

+127
-1
lines changed

5 files changed

+127
-1
lines changed

api/v2/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ func (api *API) getSilencesHandler(params silence_ops.GetSilencesParams) middlew
511511
matcher, err := labels.ParseMatcher(matcherString)
512512
if err != nil {
513513
level.Debug(logger).Log("msg", "Failed to parse matchers", "err", err)
514-
return alert_ops.NewGetAlertsBadRequest().WithPayload(err.Error())
514+
return silence_ops.NewGetSilencesBadRequest().WithPayload(err.Error())
515515
}
516516

517517
matchers = append(matchers, matcher)

api/v2/client/silence/get_silences_responses.go

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ paths:
5353
description: Get silences response
5454
schema:
5555
$ref: '#/definitions/gettableSilences'
56+
'400':
57+
$ref: '#/responses/BadRequest'
5658
'500':
5759
$ref: '#/responses/InternalServerError'
5860
parameters:

api/v2/restapi/embedded_spec.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2/restapi/operations/silence/get_silences_responses.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)