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

URL querystring missing in tracer #5432

Closed
DurandA opened this issue Jan 25, 2021 · 4 comments · Fixed by #6178
Closed

URL querystring missing in tracer #5432

DurandA opened this issue Jan 25, 2021 · 4 comments · Fixed by #6178
Labels

Comments

@DurandA
Copy link

DurandA commented Jan 25, 2021

🐞 Describe the bug

The URL querystring is not propagated to params.url in tracer callbacks.

💡 To Reproduce

import aiohttp
import asyncio

async def on_request_start(session, trace_config_ctx, params):
    print(f'{repr(params.url)}')

async def main():
    trace_config = aiohttp.TraceConfig()
    trace_config.on_request_start.append(on_request_start)
    session = aiohttp.ClientSession(trace_configs=[trace_config])
    async with session:
        params = {'key1': 'value1', 'key2': 'value2'}
        async with session.get('http://httpbin.org/get', params=params) as resp:
            print(resp.url)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

💡 Expected behavior

parms.url should contain the query string (e.g. http://httpbin.org/get?key1=value1&key2=value2).

📋 Your version of the Python

Python 3.8.5

📋 Your version of the aiohttp/yarl/multidict distributions

aiohttp 3.6.2
multidict 4.7.6
yarl 1.6.3

@DurandA DurandA added the bug label Jan 25, 2021
@vadimber18
Copy link

@DurandA on_request_exception did not actually triggered for your case, because request does not finishes with exception. You can try to change request url for invalid one to make sure on_request_exception works well when exception actually happens

@DurandA
Copy link
Author

DurandA commented Mar 20, 2021

@vadimber18 Thanks. I replaced the example with on_request_start since the querystring is missing with other signals as well.

@vadimber18
Copy link

vadimber18 commented Mar 20, 2021

@DurandA params.url is an URL object, you can get query string with params.url.query_string

for your case try this:

print(params.url.query_string)

You can check other details on yarl readme here

@DurandA
Copy link
Author

DurandA commented Mar 20, 2021

@vadimber18 Yes, query_string is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants