You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I catch errors like this while using aiohttp.web.Application():
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/aiohttp/web_protocol.py", line 332, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message:
Invalid header value char:
[...]
The client-side receives HTTP 400 with the exception text which I want to avoid (and also log the exception using my logger). It does not seem like I can catch it using middleware or override in any way which I would possibly call a bug (unless I'm missing something obvious)
Describe the bug
How can I catch errors like this while using
aiohttp.web.Application()
:The client-side receives HTTP 400 with the exception text which I want to avoid (and also log the exception using my logger). It does not seem like I can catch it using middleware or override in any way which I would possibly call a bug (unless I'm missing something obvious)
It seems like this is where this unwanted response for the client is being created: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_protocol.py#L411
To Reproduce
Expected behavior
A way to catch and handle the error in my app to log it and send back a generic error message
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
propcache Version
yarl Version
OS
Ubuntu 22.04 LTS
Related component
Server
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: