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

Upgrade to httpx 0.20.0 (request() got an unexpected keyword argument 'allow_redirects') #1488

Closed
simonw opened this issue Oct 13, 2021 · 5 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Oct 13, 2021

This is caused by a change made to httpx in https://github.com/encode/httpx/releases/tag/0.20.0

@simonw simonw added the bug label Oct 13, 2021
@simonw simonw changed the title request() got an unexpected keyword argument 'allow_redirects' Upgrade to httpx 0.20.0 (request() got an unexpected keyword argument 'allow_redirects') Oct 13, 2021
@simonw
Copy link
Owner Author

simonw commented Oct 13, 2021

Upgrading to 0.20.0 gives me lots of the following errors:

'{"ok": false, "error": "Database not found: .json?_sort=relationships", "status": 404, "title": null}'

It looks like the full query string is now being treated as the name of the database.

@simonw
Copy link
Owner Author

simonw commented Oct 13, 2021

I think the issue is in route_path():

> /Users/simon/Dropbox/Development/datasette/datasette/app.py(1182)route_path()
-> response = await view(request, send)
(Pdb) path
'/_memory.json?sql=select+sqlite_version()'

@simonw
Copy link
Owner Author

simonw commented Oct 13, 2021

(Pdb) request.scope['path']
'/_memory.json'
(Pdb) request.scope['raw_path']
b'/_memory.json?sql=select+sqlite_version()'

So raw_path now includes the query string.

@simonw
Copy link
Owner Author

simonw commented Oct 13, 2021

This is weird - as far as I can tell httpx has included the query string in raw_path for well over a year: encode/httpx@8e4a8a1#diff-c9a78eb3b5f5c4fac4e5552165fbdd5320c7e3fadf9eedabcb5461393466c090R235

@simonw
Copy link
Owner Author

simonw commented Oct 13, 2021

I think this is the change in httpx which is causing the bug for me: encode/httpx@ff9813e#diff-0d0cbe9ebcd03cc8c780b0407762540a082f70cc64257f2fcd588cc30f43c15cR96

Transport_API_as_plain_`request_-__response`_method____1840__·_encode_httpx_ff9813e

Previously it was using path from path, _, query = full_path.partition(b"?") to populate the raw_path key - but it changed to instead using request.url.raw_path which presumably implements the logic that includes the query string.

simonw added a commit that referenced this issue Oct 14, 2021
@simonw simonw closed this as completed in b267b57 Oct 14, 2021
simonw added a commit that referenced this issue Oct 14, 2021
simonw added a commit that referenced this issue Oct 24, 2021
* Upgrade to httpx 0.20, closes #1488
* TestClient.post() should not default to following redirects
simonw added a commit that referenced this issue Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant