I get the following output when receiving requests from Telegram through the installed Webhook:
Error handling request
Traceback (most recent call last):
File "G:\pyProj\lena-site\venv\Lib\site-packages\aiohttp\web_protocol.py", line 350, 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.BadStatusLine: 400, message:
Invalid method encountered:
b'":27,"length":5,"type":"bold"}]},"text":"\\u041f\\u044f\\u0442\\u044c."}}POST /telegram/hook HTTP/1.1'
^
Error handling request
Traceback (most recent call last):
File "G:\pyProj\lena-site\venv\Lib\site-packages\aiohttp\web_protocol.py", line 350, 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.BadStatusLine: 400, message:
Invalid method encountered:
b't":"CHAT_MESSAGE:\\n\\u041f\\u043e\\u043b\\u044c\\u0437\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044c Dobry \\u043d\\u0430\\u043f\\u0438\\u0441\\u0430\\u043b \\u0432 \\u0447\\u0430\\u0442:\\n\\n\\u0414\\u0430 \\u0431\\u0443\\u0434\\u0435\\u0442 \\u043f\\u044f\\u0442\\u044c.","entities":[{"offset":0,"length":13,"type":"underline"},{"offset":27,"length":5,"type":"bold"}]},"text":"\\u041f\\u044f\\u0442\\u044c."}}POST /telegram/hook HTTP/1.1'
^
...
Tests show that each such output contains a reaction to part of the line from the previous message (that is, received by the handler in the previous request), which, in principle, does not affect the operation of the script in any way. At the same time, sending the same text does not guarantee receiving a message about this error, which is why it is not possible to identify the pattern that influences the occurrence of this situation.
The method(read() | text() | json()) by which the contents of the request are received has no effect on this situation.
To Reproduce
An ordinary POST request handler that reads the content:
@routes.post("/telegram/hook")
@aiohttp_csrf.csrf_exempt
async def telegram_hook(request: Request) -> Response:
""" Receives data from Telegram, processes it
and sends a response.
"""
secret_header = request.headers.get("X-Telegram-Bot-Api-Secret-Token", None)
if secret_header != TG_SECRET_TOKEN:
log.debug(
"An incorrect secret was received in a message from Telegram:"
f"\n{secret_header!r}"
)
return Response(status=404)
body: bytes = await request.read()
...
Expected behavior
Since this exception does not affect the operation of the program in any way, I would like not to see messages about it. I haven't found a way to disable output for this particular situation.
Describe the bug
I get the following output when receiving requests from Telegram through the installed Webhook:
Tests show that each such output contains a reaction to part of the line from the previous message (that is, received by the handler in the previous request), which, in principle, does not affect the operation of the script in any way. At the same time, sending the same text does not guarantee receiving a message about this error, which is why it is not possible to identify the pattern that influences the occurrence of this situation.
The method(
read() | text() | json()
) by which the contents of the request are received has no effect on this situation.To Reproduce
An ordinary POST request handler that reads the content:
Expected behavior
Since this exception does not affect the operation of the program in any way, I would like not to see messages about it. I haven't found a way to disable output for this particular situation.
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Windows 10 x64
Related component
Server
Additional context
No response
Code of Conduct