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

fix(aiohttp): Handle invalid responses #3554

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

szokeasaurusrex
Copy link
Member

If the request handler returns an invalid response (e.g. None), our SDK triggers an error because we try to access the invalid response's status attribute. Wrap this with a try block to handle the AttributeError and ensure the SDK does not break the app.

If the request handler returns an invalid response (e.g. `None`), our SDK triggers an error because we try to access the invalid response's `status` attribute. Wrap this with a `try` block to handle the `AttributeError` and ensure the SDK does not break the app.
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.54%. Comparing base (0ee7c50) to head (dc200ac).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3554      +/-   ##
==========================================
+ Coverage   84.49%   84.54%   +0.05%     
==========================================
  Files         133      133              
  Lines       13840    13844       +4     
  Branches     2927     2927              
==========================================
+ Hits        11694    11705      +11     
+ Misses       1422     1415       -7     
  Partials      724      724              
Files with missing lines Coverage Δ
sentry_sdk/integrations/aiohttp.py 85.53% <100.00%> (+0.37%) ⬆️

... and 4 files with indirect coverage changes

@szokeasaurusrex szokeasaurusrex enabled auto-merge (squash) September 23, 2024 08:02
@szokeasaurusrex szokeasaurusrex merged commit 25ab10c into master Sep 23, 2024
124 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/aiohttp-bugfix branch September 23, 2024 08:11
szokeasaurusrex added a commit that referenced this pull request Sep 25, 2024
This test was added in #3554 to ensure that we don't break people's AIOHTTP apps when a request handler returns an invalid response. However, the test broke with a recent AIOHTTP release. After investigating, I believe the test broke because it depends on internal AIOHTTP implementation details which changed in the recent AIOHTTP release.

This test likely does not add too much value anyways, since the change in #3554 includes a comment, which explains why handling the AttributeError is important, so I think we can safely remove it.

Fixes #3567
szokeasaurusrex added a commit that referenced this pull request Sep 25, 2024
This test was added in #3554 to ensure that we don't break people's AIOHTTP apps when a request handler returns an invalid response. However, the test broke with a recent AIOHTTP release. After investigating, I believe the test broke because it depends on internal AIOHTTP implementation details which changed in the recent AIOHTTP release.

This test likely does not add too much value anyways, since the change in #3554 includes a comment, which explains why handling the AttributeError is important, so I think we can safely remove it.

Fixes #3567
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.

2 participants