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

String decoding fails for POST requests with byte payload #844

Open
thomas-maschler opened this issue Jun 5, 2024 · 4 comments
Open

String decoding fails for POST requests with byte payload #844

thomas-maschler opened this issue Jun 5, 2024 · 4 comments

Comments

@thomas-maschler
Copy link

One of my requests I am trying to record uploads an image to cloud storage.

The POST requests' payload is a byte-string (not a BytesIO object).

The body contains some non-utf-8 characters and when trying to decode them, function replace_post_data_parameters breaks

  File "/.../site-packages/vcr/filters.py", line 116, in replace_post_data_parameters
    rk = k.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 0: invalid start byte
@JonLev
Copy link

JonLev commented Jun 26, 2024

On the same idea, I have the issue of using Whisper model from OpenAI, using their official librairy, the client is HTTPx, and it send a post with bytes data. I have the same failure at a different place:
https://github.com/kevin1024/vcrpy/blob/master/vcr/stubs/httpx_stubs.py#L108

body = httpx_request.read().decode("utf-8")

So the questions are: Is this decode necessary at this moment ? How can we use VCRPY in these cases ?

@thomas-maschler
Copy link
Author

I got it to work with this patch
master...thomas-maschler:vcrpy:decode

@fiendish
Copy link

fiendish commented Jul 2, 2024

This looks like a duplicate of #660

@ddorian
Copy link

ddorian commented Jul 2, 2024

Probably needs this too 1ef75a1

sullivan-sean added a commit to develop-health/vcrpy that referenced this issue Jul 16, 2024
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

4 participants