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

DO NOT MERGE: debug test_unsupported_upgrade #7960

Closed
wants to merge 12 commits into from

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Dec 11, 2023

What do these changes do?

Are there changes in behavior for the user?

Related issue number

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 news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@bdraco bdraco mentioned this pull request Dec 11, 2023
11 tasks
@bdraco bdraco closed this Dec 11, 2023
@bdraco bdraco reopened this Dec 11, 2023
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: Patch coverage is 92.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 97.52%. Comparing base (aa014a9) to head (0ded1a2).

Files Patch % Lines
tests/test_web_server.py 80.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7960      +/-   ##
==========================================
- Coverage   97.53%   97.52%   -0.01%     
==========================================
  Files         107      107              
  Lines       32843    32886      +43     
  Branches     3851     3854       +3     
==========================================
+ Hits        32032    32073      +41     
- Misses        610      613       +3     
+ Partials      201      200       -1     
Flag Coverage Δ
CI-GHA 97.43% <90.00%> (-0.01%) ⬇️
OS-Linux 97.09% <90.00%> (-0.02%) ⬇️
OS-Windows 95.79% <88.37%> (+0.16%) ⬆️
OS-macOS 96.92% <90.00%> (+<0.01%) ⬆️
Py-3.10.11 95.52% <79.06%> (-0.03%) ⬇️
Py-3.10.13 96.78% <82.00%> (-0.14%) ⬇️
Py-3.10.14 96.66% <88.00%> (?)
Py-3.11.8 96.88% <88.00%> (+0.32%) ⬆️
Py-3.12.2 97.00% <88.00%> (+0.28%) ⬆️
Py-3.8.10 95.50% <81.39%> (-0.02%) ⬇️
Py-3.8.18 96.84% <88.00%> (-0.02%) ⬇️
Py-3.9.13 95.49% <81.39%> (-0.02%) ⬇️
Py-3.9.18 96.87% <88.00%> (-0.02%) ⬇️
Py-pypy7.3.15 96.40% <88.00%> (-0.02%) ⬇️
VM-macos 96.92% <90.00%> (+<0.01%) ⬆️
VM-ubuntu 97.09% <90.00%> (-0.02%) ⬇️
VM-windows 95.79% <88.37%> (+0.16%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2023

its getting stuck at

message, payload = await protocol.read() # type: ignore[union-attr]

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2023

                        if not empty_body and (
                            (length is not None and length > 0)
                            or msg.chunked
                            and not msg.upgrade
                        ):
                            payload = StreamReader(
                                self.protocol,
                                timer=self.timer,
                                loop=loop,
                                limit=self._limit,
                            )
                            payload_parser = HttpPayloadParser(

msg.upgrade is set, so we don't ever read the payload so it times out

import pprint

pprint.pprint(["upgraded", msg.upgrade, msg])
self._upgraded = code == 101 and msg.upgrade
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -505,6 +517,9 @@ def parse_headers(
close_conn = False
# https://www.rfc-editor.org/rfc/rfc9110.html#name-101-switching-protocols
elif v == "upgrade" and headers.get(hdrs.UPGRADE):
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this the source of the problem for #6446? Just because the Upgrade header has content, doesn't mean there will be an upgrade. The server has every right to ignore it if the scheme is unsupported.

Copy link
Member

Choose a reason for hiding this comment

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

If you think you can provide a fix, that'd be great. I believe there is already an xfail test from that issue, so as long as you can get that test passing..

Copy link
Member

Choose a reason for hiding this comment

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

One problem at a time for this newbie... Brotli first 😉

import pprint

pprint.pprint(["handler except", e])
raise

upgrade_headers = {"Connection": "Upgrade", "Upgrade": "unsupported_proto"}
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 not sure what is parsing the Upgrade header, but the fact that it's not a valid token at all should also be considered (IANA upgrade token registry. In fact, it even contains an invalid character, "_", for URL schemes (RFC 1738).

Copy link
Member

Choose a reason for hiding this comment

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

I would assume that would be handled in the parsers (i.e. llhttp or http_parser.py, depending on whether extensions are enabled).

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay. My point is, especially it it happens externally, the test should know and account for the behavior.

I would hope, no matter which parser is used, that "unsupported_proto" would simply be thrown away and equivalent to "". Then the test should also test a valid, but unsupported, token.

await resp.start(conn)
except BaseException:
except BaseException as ex:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
resp.close()
raise
except BaseException:
except BaseException as ex:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
@bdraco
Copy link
Member Author

bdraco commented Mar 26, 2024

Looks like its an actual bug and the test only passed because of a race

#8252

@bdraco bdraco closed this Mar 26, 2024
@bdraco bdraco reopened this Mar 26, 2024
@bdraco bdraco closed this Mar 26, 2024
@Dreamsorcerer Dreamsorcerer deleted the unsupported_upgrade_test branch April 11, 2024 22:20
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.

3 participants