-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 eroneous, incorrect, Client error "invalid constant string" #3641
Comments
GitMate.io thinks the contributor most likely able to help you is @asvetlov. Possibly related issues are #3242 (Error), #1753 (aiohttp.errors is gone), #3251 (Aiohttp Client request limit), #2624 (aiohttp client throws http errors for the following redirect), and #2635 (Unclosed client session Error in aiohttp.request). |
@nhumrich can you explain what produces this response? You assumption on the importance of the source of For example,
Chrome also swallows the unexpected body without error. Thus, if |
@dimaqq I believe it's produced by |
|
You probably don't have build deps then. Also, we ship OS-specific wheels so you don't have to compile anything during install time. |
ok, good call, here is the result of curl:
So, you might be right, the server probably is sending something. That helps. Thanks! I would still like to keep this issue open, to change the error, and how it is presented to the user. Because Also, perhaps, aiohttp could also act like most clients, and simply not read the body when the content-length is 0. |
- Prevent us from storing errorneous status code in response code stats References: aio-libs/aiohttp#3641
- Prevent us from storing errorneous status code in response code stats References: aio-libs/aiohttp#3641
- Prevent us from storing errorneous status code in response code stats References: aio-libs/aiohttp#3641
Parsing etc. has changed substantially since this issue was opened. Can you retest if the problem still exists? |
Long story short
aiohttp is returning
400, message='invalid constant string'
when nothing is actually wrong with the request or response.Expected behaviour
I get the response object, which should be a 204
Actual behaviour
when I send a request, and get a 204 back, aiohttp throws this stack trace:
I have tried to debug this as much as possible, but got stuck, and this is as far as I got. I noticed that in
client_proto.py
line 195 (as seen in the stack trace) that data is set toAs you can see, there is a weird
null
at the end, even though content-length is 0. Wondering if this was a weird server bug, I tried to see what requests did and if I use requests-toolbelt to dump the raw response data, doing the exact same thing, the response has nonull
at the end:If I call the same endpoint in the browser, there is no body shown.
Unfortunately, this is a private endpoint that requires authentication, so I cant send a url to reproduce.
But using that string about for data, you can reproduce the error. I have attempted to replace the data, and remove
null
, and if I remove thenull
at the end manually, (by editing aiohttp code locall, or using the debugger), everything works perfectly. The issue is thatnull
is getting at the end somehow, and I am not sure how. I tried to put the debugger up higher in the stack, nearread()
in client_reqrep.py, but ended up getting very different errors, that seam to be race conditions with the headers when I attach a debugger.Anyways, any thoughts as how the
null
is getting there?This is actually a two-fold bug. First, the error makes it look like its a client error by sending a
400
. I spent a significant amount of time thinking that the error was coming from the server because of the 400 status code. It would be great if this error made it more clear that the "server response" was invalid, and not my request.But second, why is the
null
there, when no other client has it? Can this issue be solved?Your environment
aiohttp==3.4.4
python==3.7.2
os==linux 4.20.5
using the client only.
any followup questions?
The text was updated successfully, but these errors were encountered: