-
Notifications
You must be signed in to change notification settings - Fork 107
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
[BUG] 429 error does not follow standard error format #522
Comments
@martingrzzler thanks for the report. |
If I'm not mistaken the 429 Error will be mapped to {
Name: "Too many requests",
Resp: &opensearch.Response{
StatusCode: http.StatusTooManyRequests,
Body: io.NopCloser(strings.NewReader("429 Too Many Requests /testindex/_bulk")),
},
WantedErrors: []error{opensearch.ErrNonJSONError},
}, Perhaps a ErrTooManyRequests should be added to the sentinels? ErrUnauthorized = errors.New(http.StatusText(http.StatusUnauthorized))
ErrTooManyRequests = errors.New(http.StatusText(http.TooManyRequests)) |
@martingrzzler Yes, it should. Want to contribute a test + fix? |
Adding this for now is okay but maybe instead of doing: if !json.Valid(body) {
if resp.StatusCode == http.StatusUnauthorized {
return ErrUnauthorized
}
return ErrNonJSONError
} We can do: if !json.Valid(body) {
return fmt.Errorf("%w, %s",ErrNonJSONError, body )
} Or even omit the ErrNonJSONError from the error. I am not sure how good this will scale if we have some more error codes that have a non json response on error. |
@Jakob3xD I've went with the approach you suggested without the |
Signed-off-by: Martin Gressler <martin.gressler@code.berlin>
What is the bug?
opensearchapi.parseError
does not handle429
correctly and instead returnsfailed to json unmarshal body
as the body does not follow theopensearchapi.Error
format.What is the expected behavior?
I ran into this by calling
Bulk
. A 429 Error is expected instead of the unmarshalling error.The text was updated successfully, but these errors were encountered: