Skip to content
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

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

Open
hitrust opened this issue Jul 14, 2024 · 1 comment
Open

Comments

@hitrust
Copy link

hitrust commented Jul 14, 2024

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

bymoye added a commit to bymoye/BlackSheep that referenced this issue Jul 29, 2024
@bymoye
Copy link
Contributor

bymoye commented Jul 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants