-
-
Notifications
You must be signed in to change notification settings - Fork 158
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: Parser.parse doesn't work after request body was read. #174
Comments
Good catch. Would you like to send a PR? |
Yeah. I will try to create a PR :). But this issue is sort of issue of |
Thanks! Good call on reporting that issue on aiohttp; looks like the maintainers are open to changing the behavior or adding a separate method. Since webargs will need to support the current releases of aiohttp, it will need to be fixed in webargs, so a PR would be greatly appreciated. |
I just read the discussions in aio-libs/aiohttp#2005.
IIUC, we should change This would fix both this and #186. @ariddell, @ku3o, would you like to try that? There might be another issue, though. In https://github.com/sloria/webargs/blob/dev/dev-requirements-py3.txt, it says:
So webtest-aiohttp might require an update. |
Yeah, we're pinning to aiohttp<2 because of webtest-aiohttp. I haven't yet found a way to make webtest-aiohttp compatible with newer versions. I'm considering just rewriting the aiohttpparser's tests to use aiohttp's built-in testing client. |
Actually, I was able to get webtest-aiohttp working with aiohttp 2, so we can finally move forward with getting the aiohttpparser up to date. I think it will be pretty straightforward. Question is: is dropping support for aiohttp 1 considered a breaking change? aiohttp isn't a hard dependency of webargs, but breakages may occur for users of the aiohttpparser module, so I'm thinking we bump to webargs 2.0.0. Thoughts @lafrech @ku3o ? |
The question could be how long you'd be maintaining webargs 1.x. A compromise would be bump to 2.0.0 to be on the safe side, but deprecate 1.x right away to urge people to upgrade. This is acceptable as the upgrade would be easy. From your perspective, it is pretty much the same as releasing this as a minor change, except it is more explicit about the breaking change; |
The release of I think bumping version to |
OK, thank you both for your input. @lafrech I'm not sure if this is the same as what you're suggesting, but I think we'll go with the following path:
|
Yes, this is what I meant. What I also tried to say is that moving to 2.0.0 should be straightforward for the clients, so it is fair to abandon 1.x branch right after 1.10.0 and 2.0.0 are released. There is no point in maintaining both branches in parallel, as there shouldn't be users stuck to 1.x. Maybe this means adding a deprecation warning on the 1.x branch to tell people to move to 2.x. |
@lafrech. I agree. Ok, I'll release those when I'm off the clock. |
OK, both 1.10.0 and 2.0.0 are released. @ku3o Is this issue still unsolved? |
I think it solved @sloria |
Great! |
When a content of a request is read before
parser.parse
is called (withlocation=('json',)
), parser returns that JSON fields are missing in the request.Example code:
The issue is the following line of code https://github.com/sloria/webargs/blob/dev/webargs/aiohttpparser.py#L92 specifically
req.has_body
. This attribute has an unfortunate name and it's not constant over a lifetime of a request. It checks if there are more bytes to read. Once the body is read byawait request.json()
there are no more bytes to read and value ofreq.has_body
isFalse
.The text was updated successfully, but these errors were encountered: