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

[3.8] Backport fix for setting cookies #5233

Merged
merged 9 commits into from
Nov 29, 2020
Merged

[3.8] Backport fix for setting cookies #5233

merged 9 commits into from
Nov 29, 2020

Conversation

Dreamsorcerer
Copy link
Member

@Dreamsorcerer Dreamsorcerer commented Nov 14, 2020

I see this fix in master, but this needs to be released on the 3.7 branch, as aiohttp-session is broken without this.

(cherry-picked from 54afac7)

@asvetlov
Copy link
Member

Could you please refer to the master's commit with the fix?

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Nov 14, 2020
@CLAassistant
Copy link

CLAassistant commented Nov 14, 2020

CLA assistant check
All committers have signed the CLA.

@Dreamsorcerer
Copy link
Member Author

It's this one: 54afac7

Appears to be part of a more substantial change in aiohttp4 (where HTTPException is no longer subclassing Response). This single line I've taken from there is enough to fix the behaviour in v3.7.

@codecov
Copy link

codecov bot commented Nov 14, 2020

Codecov Report

Merging #5233 (ddd00f7) into 3.8 (8ce3013) will increase coverage by 0.01%.
The diff coverage is 94.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##              3.8    #5233      +/-   ##
==========================================
+ Coverage   97.53%   97.55%   +0.01%     
==========================================
  Files          44       44              
  Lines        8844     8818      -26     
  Branches     1424     1419       -5     
==========================================
- Hits         8626     8602      -24     
+ Misses        102      101       -1     
+ Partials      116      115       -1     
Flag Coverage Δ
unit 97.39% <94.89%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiohttp/hdrs.py 100.00% <ø> (ø)
aiohttp/http_websocket.py 98.67% <ø> (ø)
aiohttp/locks.py 92.85% <0.00%> (ø)
aiohttp/resolver.py 95.16% <ø> (ø)
aiohttp/web_middlewares.py 100.00% <ø> (ø)
aiohttp/web_routedef.py 98.09% <66.66%> (ø)
aiohttp/streams.py 97.94% <80.00%> (+0.48%) ⬆️
aiohttp/multipart.py 96.97% <85.71%> (ø)
aiohttp/client_reqrep.py 97.20% <87.50%> (-0.02%) ⬇️
aiohttp/__init__.py 100.00% <100.00%> (ø)
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88f8f3b...eee5eea. Read the comment docs.

@Dreamsorcerer
Copy link
Member Author

That test appears to have passed on the previous commit, so I think it's just flaky (given that I only added a CHANGE file in this commit).

@Dreamsorcerer Dreamsorcerer changed the title Backport fix for setting cookies [3.7] Backport fix for setting cookies Nov 14, 2020
@Dreamsorcerer
Copy link
Member Author

I've added a simplified version of the test in aiohttp-session, which should catch regressions.

@asvetlov
Copy link
Member

Cool! I'll take a review soon

@@ -426,6 +426,7 @@ async def _handle_request(
resp = Response(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but the fix is incorrect.
This line was backported by the incident.
Since in aiohttp 3.x HttpException is derived from Response we should just use it as-is without the creation of intermediate response object.
I believe this line was incorrectly backported by #4771

I apologize for the regression.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I'll just update this with the reverted code then.

Appears to actually have been this commit, which moved some of the logic into a new _handle_request() method:
29eccad#diff-2126b277e07e3fdd05e7a81da456accf24e5515a46c78c48a79db4eb166043e4L373

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, not so easy. Now getting ServerDisconnectedError in the tests.
Will take a look later in the week, unless you beat me to it.

@Dreamsorcerer
Copy link
Member Author

OK, reverting back to using the exception as the response seems to require moving the exception handler back to the parent function in order to handle the deprecation warning correctly. I think that's working now though.

@Dreamsorcerer
Copy link
Member Author

Flaky test? Seems odd that the changes would fail on macos only. Also the CI seems to be struggling, it fails to load the test log half of the time I try to look at it.

@thijstriemstra
Copy link
Contributor

+1! Also ran into this issue and reverted aiohttp to 3.6.3 for now.

@Dreamsorcerer
Copy link
Member Author

Looking back at my previous comments, the current test failure is the same one from earlier, which is just flaky, as it failed on one commit and passed on the next despite only changing documentation.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is correct but please move your changes into _handle_request; it reduces the diff between the master and backport branches.

Also, I would freeze 3.7 branch but publish aiohttp 3.8 soon.
Please use 3.8 as the base branch for PR.

aiohttp/web_protocol.py Outdated Show resolved Hide resolved
@Dreamsorcerer Dreamsorcerer changed the base branch from 3.7 to 3.8 November 29, 2020 13:50
@thijstriemstra
Copy link
Contributor

maybe change the pr title as well.

@Dreamsorcerer Dreamsorcerer changed the title [3.7] Backport fix for setting cookies [3.8] Backport fix for setting cookies Nov 29, 2020
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Nov 29, 2020

This pull request introduces 2 alerts and fixes 1 when merging eee5eea into 5d1a75e - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Missing call to __init__ during object initialization

fixed alerts:

  • 1 for __eq__ not overridden when adding attributes

@Dreamsorcerer
Copy link
Member Author

Dreamsorcerer commented Nov 29, 2020

First time I've seen a failure from lgtm. :P
Appears to be from the merge though, not related to the PR (in fact, it's stopped failing since the target branch has been changed).

@asvetlov
Copy link
Member

Then I see lgtm alerts I usually open "view on LGTM.com" link, analyze it, and close as "I don't care" or "false alarm".
But sometimes it is helpful as a point at "bad smelling" code.

@asvetlov asvetlov merged commit bb04402 into aio-libs:3.8 Nov 29, 2020
@asvetlov
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants