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

Include parsed error info in TransportError in async connections #226

Merged
merged 1 commit into from
May 9, 2023

Conversation

gg-kialo
Copy link
Contributor

Fixes #225

Signed-off-by: Gordon Govan gg@kialo.com

Description

Parses the error into the info field of TransportExceptions 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.

Copy link
Member

@dblock dblock left a 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)
Copy link
Member

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))

@gg-kialo gg-kialo force-pushed the fix/225-async-errors branch 2 times, most recently from 5eb2b0e to 9e7ecef Compare October 26, 2022 17:10
@gg-kialo gg-kialo marked this pull request as draft October 26, 2022 17:15
@gg-kialo
Copy link
Contributor Author

gg-kialo commented May 3, 2023

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.

@dblock
Copy link
Member

dblock commented May 3, 2023

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 opensearchpy/_async/http_aiohttp.py should be tested in .../_async/test_http_aiohttp.py.

@gg-kialo gg-kialo force-pushed the fix/225-async-errors branch 2 times, most recently from 25603bc to caaaf6c Compare May 4, 2023 12:29
@gg-kialo gg-kialo marked this pull request as ready for review May 4, 2023 12:29
@gg-kialo
Copy link
Contributor Author

gg-kialo commented May 4, 2023

@dblock I've added a test and resolved the conflicts.

Copy link
Member

@dblock dblock left a 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.

data, headers_response.get("content-type")
) where we do lowercase content-type. Is the map not case-sensitive? Is it always 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-commenter
Copy link

codecov-commenter commented May 4, 2023

Codecov Report

Merging #226 (caab1c3) into main (2abb8c4) will increase coverage by 0.66%.
The diff coverage is 100.00%.

❗ 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     
Impacted Files Coverage Δ
opensearchpy/_async/http_aiohttp.py 82.81% <100.00%> (+3.12%) ⬆️

... and 15 files with indirect coverage changes

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>
@gg-kialo
Copy link
Contributor Author

gg-kialo commented May 8, 2023

@dblock, yes, headers is a CIMultiDictProxy (where CI is case-insensitive).

@dblock dblock merged commit 707373e into opensearch-project:main May 9, 2023
@gg-kialo gg-kialo deleted the fix/225-async-errors branch May 10, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] additional info missing from TransportError when using async
3 participants