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

Handle zstd encoding #230

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

viginum-datalab
Copy link

@viginum-datalab viginum-datalab commented Jan 15, 2025

Issue description

Sometimes, with big responses, I get the following error:

Err: <class 'UnicodeDecodeError'>: 'utf-8' codec can't decode byte 0xb8 in position 1: invalid start byte

Fixes: #185

Investigation

So I opened my web browser and took a look at the headers.

Request:

Accept-Encoding: gzip, deflate, br, zstd

Response:

content-encoding: zstd

Examining the response data shows it was indeed compressed by the zstd algorithm. Because it wasn't handled, it raised a UnicodeDecodeError that was catched by the general exception in queue_client.py line 38.

Solution

I added zstd to the project dependency and decoded the response content depending on its content-encoding header.

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

Successfully merging this pull request may close these issues.

Err: <class 'UnicodeDecodeError'>: 'utf-8' codec can't decode byte 0xb8 in position 1: invalid start byte
1 participant