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 version (<3.10.7) issue with host header having port specified or IPv6 IP #2192

Closed
babs opened this issue Nov 23, 2024 · 2 comments · Fixed by #2190
Closed

aiohttp version (<3.10.7) issue with host header having port specified or IPv6 IP #2192

babs opened this issue Nov 23, 2024 · 2 comments · Fixed by #2190
Assignees
Labels
bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team.

Comments

@babs
Copy link

babs commented Nov 23, 2024

Version

botbuilder-integration-aiohttp 4.16.2

Describe the bug

botbuilder-integration-aiohttp-4.16.2 is dependant of aiohttp-3.10.5 but aiohttp-3.10.5 suffers an issue that seems to be fixed in aiohttp-3.10.7.

Issue is you can't use the Request.url property if the host header contains port or is IPv6 IP.

To Reproduce

Steps to reproduce the behavior:

  1. create a basic example of bot (or see bellow for a smaller reproducible issue)
  2. in the handler, just print or use request.url
  3. witness the 500 response

Expected behavior

I'd expect the request to not fail and get the object as expected

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

full repro case

mkdir /tmp/aiohttp-issue
cd /tmp/aiohttp-issue
python3 -m venv .venv
. .venv/bin/activate
pip install aiohttp==3.10.5 # version botbuilder-integration-aiohttp-4.16.2 is using


cat > example.py <<EOF
from aiohttp import web

async def hello(request):
    return web.Response(text=f"Hello, world: {request.url.path}")

app = web.Application()
app.add_routes([web.get('/', hello)])

web.run_app(app)
EOF

python3 example.py

output when curl localhost:8080 from another terminal:

======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Error handling request
Traceback (most recent call last):
  File "/tmp/aiohttp-issue/.venv/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/aiohttp-issue/.venv/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/aiohttp-issue/example.py", line 4, in hello
    return web.Response(text=f"Hello, world: {request.url.path}")
                                              ^^^^^^^^^^^
  File "aiohttp/_helpers.pyx", line 26, in aiohttp._helpers.reify.__get__
  File "/tmp/aiohttp-issue/.venv/lib/python3.12/site-packages/aiohttp/web_request.py", line 453, in url
    url = URL.build(scheme=self.scheme, host=self.host)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/aiohttp-issue/.venv/lib/python3.12/site-packages/yarl/_url.py", line 386, in build
    _host = _encode_host(host, validate_host=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/aiohttp-issue/.venv/lib/python3.12/site-packages/yarl/_url.py", line 1496, in _encode_host
    raise ValueError(
ValueError: Host 'localhost:8080' cannot contain ':' (at position 9)

Upgrade aiohttp, it works fine

pip install aiohttp==3.10.7
python3 example.py 
@babs babs added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Nov 23, 2024
@babs
Copy link
Author

babs commented Nov 23, 2024

should be fixed by #2190

babs added a commit to teams-notifier/bf-directline-endpoint that referenced this issue Nov 23, 2024
@gandiddi gandiddi self-assigned this Nov 25, 2024
@gandiddi gandiddi linked a pull request Nov 25, 2024 that will close this issue
@vavsab
Copy link

vavsab commented Dec 30, 2024

@tracyboehrer is it possible to create a release so we could use this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants