BlackSheep icon indicating copy to clipboard operation
BlackSheep copied to clipboard

TypeError: 'in <string>' requires string as left operand, not bytes

Open hitrust opened this issue 1 year ago • 1 comments

Describe the bug A description of what the bug is, possibly including how to reproduce it.

2024-07-14 01:01:14,382-14-ERROR-Unhandled exception - "POST /wechat?signature=8fa7d50f1cac4556336b1b64386df3e49cb48fde&timestamp=1720918873&nonce=2147035210&openid=omaqTs24GgB2wEINZwL0Ybo5pXtg&encrypt_type=aes&msg_signature=217f303f3391d560c77277df82f4e96f71eabd72" Traceback (most recent call last): File "blacksheep/baseapp.pyx", line 81, in blacksheep.baseapp.BaseApplication.handle File "/usr/local/lib/python3.12/site-packages/blacksheep/middlewares.py", line 6, in middleware_wrapper return await handler(request, next_handler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/sessions/init.py", line 156, in call response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/middlewares.py", line 6, in middleware_wrapper return await handler(request, next_handler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/server/authentication/init.py", line 19, in authentication_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/middlewares.py", line 6, in middleware_wrapper return await handler(request, next_handler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/server/authorization/init.py", line 82, in authorization_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/middlewares.py", line 6, in middleware_wrapper return await handler(request, next_handler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/server/compression.py", line 106, in call if not self.should_handle(request, response): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/server/compression.py", line 96, in should_handle return is_handled_encoding() and is_handled_response_content() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/blacksheep/server/compression.py", line 78, in is_handled_encoding return b"gzip" in (request.get_first_header(b"accept-encoding") or "") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'in ' requires string as left operand, not bytes

hitrust avatar Jul 14 '24 01:07 hitrust

It seems that the problem lies in the lack of accept-encoding header, which causes it to take the empty string on the right by default, but the left side is bytes, which causes the problem.

bymoye avatar Jul 29 '24 03:07 bymoye

Closing because this was fixed at 2.0.8.

RobertoPrevato avatar Apr 21 '25 19:04 RobertoPrevato