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

aiohttp/web.py: fixing middleware resolution order accross multiple applications #1854

Merged
merged 3 commits into from
May 12, 2017

Conversation

Anvil
Copy link
Contributor

@Anvil Anvil commented Apr 28, 2017

What do these changes do?

This should fix #1853

Are there changes in behavior for the user?

Yes, likely.

Related issue number

#1853

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new entry to CHANGES.rst
    • Choose any open position to avoid merge conflicts with other PRs.
    • Add a link to the issue you are fixing (if any) using #issue_number format at the end of changelog message. Use Pull Request number if there are no issues for PR or PR covers the issue only partially.

@Anvil
Copy link
Contributor Author

Anvil commented Apr 28, 2017

I honestly don't know if the right way is what I've done, or changing the match_info.add_app method behavior, since I don't know if there would be unwanted any side effect.

But in any case, you've got the point: the list match_info.apps list should be reversed.

@fafhrd91
Copy link
Member

That's probably regression in 2.x version.

@asvetlov could you look?

@codecov-io
Copy link

codecov-io commented Apr 28, 2017

Codecov Report

Merging #1854 into 2.0 will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##              2.0    #1854   +/-   ##
=======================================
  Coverage   96.71%   96.71%           
=======================================
  Files          37       37           
  Lines        7433     7433           
  Branches     1294     1294           
=======================================
  Hits         7189     7189           
  Misses        114      114           
  Partials      130      130
Impacted Files Coverage Δ
aiohttp/web.py 97.4% <100%> (ø) ⬆️

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 a17d55e...68d351d. Read the comment docs.

@asvetlov
Copy link
Member

I'll have a time for it tomorrow evening.

@asvetlov asvetlov self-assigned this Apr 28, 2017
@asvetlov
Copy link
Member

@Anvil could you add a unit test?

@Anvil
Copy link
Contributor Author

Anvil commented May 2, 2017

The test is actually already written, but with a wrong assumption. I'll fix that.

@Anvil
Copy link
Contributor Author

Anvil commented May 2, 2017

See, Application inherits from MutableMapping, which leads to app == subapp1 == subapp2 being True in test_subapp_middlewares, because all their keys and matching values are equal. Same way as dict(foo=1) == dict(foo=1) is also True.

@Anvil
Copy link
Contributor Author

Anvil commented May 2, 2017

FTR, I think many tests are broken because of this assumption.

@fafhrd91
Copy link
Member

fafhrd91 commented May 2, 2017

@asvetlov ping

@asvetlov
Copy link
Member

asvetlov commented May 3, 2017

See #1866 (comment)

@Anvil
Copy link
Contributor Author

Anvil commented May 4, 2017

Do you want me to revert the changes on the test so that we can close this MR and the corresponding issue ?

@asvetlov
Copy link
Member

asvetlov commented May 5, 2017

Yes. Let's fix application comparison (and middleware ordering along with other potential issues).

@fafhrd91
Copy link
Member

fafhrd91 commented May 8, 2017

@asvetlov what is the status on this PR? whet is next?

@Anvil
Copy link
Contributor Author

Anvil commented May 10, 2017

I've rolled back the commits on the unit tests, yesterday. So, IMHO, it's good to merge. And I'd be interested in a bugfix release in the next few weeks, to be honest. ;)

@fafhrd91
Copy link
Member

@Anvil could you rebase against master?

@Anvil Anvil changed the base branch from 2.0 to master May 11, 2017 08:01
@Anvil
Copy link
Contributor Author

Anvil commented May 11, 2017

Done. FWIW, this bug is a blocker here. We'd like to see it fixed in 2.0 series, if possible.

@fafhrd91
Copy link
Member

I don't think this is good fix for 2.0 This change changes behavior, even if it is broken behavior
I am planing to publish 2.1 this weekend.

@asvetlov @kxepal any comment?

@kxepal
Copy link
Member

kxepal commented May 11, 2017

I think this is indeed a breaking change, even if it's fixes the issue. It is indeed about behaviour change.

The change itself looks reasonable and good for me. I would only be a bit more clear and correct about it in change log.

The Fix sub-application middlewares resolution order means resolution order was broken in some way. It actually wasn't, but it was different and it's now reversed. Small addition about what exactly changed, why and how upgrade to new behaviour could solve a lot of questions and save people from WTF times. I hope.

@fafhrd91 fafhrd91 merged commit 29be8ac into aio-libs:master May 12, 2017
@fafhrd91
Copy link
Member

thanks!

I am planing to release 2.1 this weekend

@Anvil
Copy link
Contributor Author

Anvil commented May 15, 2017

Thanks for the merge.

@Anvil Anvil deleted the fix-middleware-order branch May 15, 2017 07:24
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sub app middlewares are called before main app,
5 participants