-
Notifications
You must be signed in to change notification settings - Fork 186
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
Include parsed error info in TransportError in async connections #226
Conversation
961a130
to
2207242
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this include the error info? I see you add content-type.
Either way needs a test, please.
CHANGELOG.md
Outdated
@@ -12,8 +12,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | |||
### Removed | |||
|
|||
### Fixed | |||
- Include parsed error info in TransportError in async connections (TODO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a link here to the PR
([#226](https://github.com/opensearch-project/opensearch-py/pull/226))
5eb2b0e
to
9e7ecef
Compare
9e7ecef
to
802aed5
Compare
802aed5
to
7c80d4d
Compare
Any hints as to where I could add a test? https://github.com/opensearch-project/opensearch-py/blob/main/test_opensearchpy/test_async/test_connection.py would seem like a good choice, but those tests are using httpbin.org, which doesn't provide an endpoint that returns both a error code and a json body. |
I generally have a very dumb approach to this, so a change in |
25603bc
to
caaaf6c
Compare
@dblock I've added a test and resolved the conflicts. |
caaaf6c
to
0b99eb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more. I see places (e.g.
opensearch-py/opensearchpy/transport.py
Line 420 in 2abb8c4
data, headers_response.get("content-type") |
Content-Type
?
If so, let's lowercase content-type
in the get
just like elsewhere in the code and leave Content-Type
in the test capitalized to show it works?
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #226 +/- ##
==========================================
+ Coverage 71.44% 72.11% +0.66%
==========================================
Files 77 77
Lines 7190 7190
==========================================
+ Hits 5137 5185 +48
+ Misses 2053 2005 -48
|
Passing the Content-Type to `_raise_errors` will cause the json body to be parsed and included in the `TransportError`. This matches the behaviour of the sync client. Fixes opensearch-project#225 Signed-off-by: Gordon Govan <gg@kialo.com>
0b99eb8
to
caab1c3
Compare
@dblock, yes, |
Fixes #225
Signed-off-by: Gordon Govan gg@kialo.com
Description
Parses the error into the
info
field ofTransportException
s in the async connection to match the behaviour of the sync connection.Issues Resolved
Closes #225
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.