-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Async methods throw exceptions on all 4xx/5xx errors #654
Comments
This is very much a bug in fact both examples you give still return data on a 404 and so
|
Ok several things went wrong here:
Tests all the possible combinations for NEST/Elasticsearch.NET calling endpoints that should be valid or not both with a client that throws and one that does not. |
Oh yeah huge 👍 💯 on finding this @Aaronaught |
The documentation states that HTTP errors do not throw exceptions, and this is true for the synchronous methods and was true in the much older (0.20) version of NEST.
However, in the current version (1.0.0-beta1), the async methods will always throw an exception if a 4xx/5xx status is encountered.
Simple repro: execute
await client.Raw.DeleteAsync(index, type, id)
where the combination ofindex, type, id
points to a document that doesn't exist. This will generate a 404 error and subsequently throw aMaxRetryException
.Stepping further into the source, the retry logic is being triggered because
SuccessOrKnownError
isfalse
on the response, which is because theHttpStatusCode
is actuallynull
. I think the exception is actually bubbling up directly from theWebRequest.EndGetResponse
and simply not being caught properly by the task continuation logic.At the moment I can't use the async methods because of this. Even doing a
HEAD
request (i.e.DocumentExistsAsync
) will throw an exception on a 404, which doesn't make a whole lot of sense.I assume this is a bug and not an intentional design change?
The text was updated successfully, but these errors were encountered: