- Notifications
You must be signed in to change notification settings - Fork 30
fix: aiohttp.ClientResponse.data should be awaited #197
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
Conversation
…uring HTTP exception handling
@extreme4all and @demetere let me know if I missed something. This functionality is super important to handle http statuses correctly. |
@cmbernard333 The two-line change itself is indeed straightforward, but the main challenge I've been facing is writing a test case that captures the issue. Right now, the tests pass both with and without the change, which suggests we're missing coverage for that edge case. I'm currently digging into the existing tests to understand what's already covered and where a new test would best fit to reflect the problem we're addressing. That's why I haven’t opened a PR just yet. |
Interesting. I can consistently make it fail, prior to any changes, by passing bad data to the /check api when using it in asynchronous mode in my own code. Let me see if I can’t pull a test together. |
After reviewing the tests in the repo, and unless I'm missing something entirely, there doesn't appear to be a good way to test this inside the repo itself since everything appears to be mocked. I can repeatedly reproduce this with the openfga python-sdk talking to a local openfga instance just by passing bad data to Any proposal here on testing it properly is appreciated. |
@demetere one more note: the failure is reproducible most when using async, hence the need to check for |
I know I am being annoying. Its annoying this occurs constantly for me in my testing. It is definitely not an edge case when running with async. I can easily reproduce it with the SDK via the following:
Then it produces this stack trace
|
Sadly I do not have any leads on that, that was the sole reason for not opening PR from my side, Let ask the opinion of maintainers |
Is there any update on this one? |
Hi all. Thanks @cmbernard333 and @demetere for really digging into this issue. During our backlog review this week, we can assign someone to help and get more eyes on this. |
Codecov ReportAttention: Patch coverage is
❌ Your project status has failed because the head coverage (70.67%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@ ## main #197 +/- ## ========================================== - Coverage 70.67% 70.67% -0.01% ========================================== Files 134 134 Lines 10868 10870 +2 ========================================== + Hits 7681 7682 +1 - Misses 3187 3188 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thanks for making this PR, @cmbernard333! One minor adjustment I'd suggest here, but otherwise looks good.
Code review Co-authored-by: Evan Sims <hello@evansims.com>
WalkthroughA conditional block was added to the asynchronous Changes
Sequence Diagram(s)sequenceDiagram participant Caller participant RESTClientObject participant aiohttp.ClientResponse Caller->>RESTClientObject: handle_response_exception(response) alt response is aiohttp.ClientResponse and lacks data RESTClientObject->>aiohttp.ClientResponse: read() RESTClientObject->>aiohttp.ClientResponse: set data attribute end RESTClientObject->>RESTClientObject: process exception handling logic 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File ( |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openfga_sdk/rest.py
(1 hunks)
🧰 Additional context used
🪛 Flake8 (7.2.0)
openfga_sdk/rest.py
[error] 282-282: multiple spaces before operator
(E221)
Make the bot happy Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Thanks again @cmbernard333, appreciate it! |
Fixes issue #184 where aiohttp.ClientResponse data wasn't being awaited on. Credit to @extreme4all and @demetere for doing the actual investigation work here.
Description
Added awaiting for the response data inside of the exception handler so that it is safe to read the response status.
References
Review Checklist
main
Summary by CodeRabbit