-
Notifications
You must be signed in to change notification settings - Fork 389
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
POSTing binary data as bytes or bytearray instead of BytesIO breaks assumptions baked into replace_post_data_parameters #660
Labels
Comments
Edit: I was wrong, tried downgrading and it made no difference. |
Here's a sample request body that is causing an error.
The request being made is below. Debugger paused at: https://github.com/kevin1024/vcrpy/blob/master/vcr/stubs/__init__.py#L257 >>> __file__
'{{ ENVIRONMENT PATH REDACTED }}/lib/python3.10/site-packages/vcr/stubs/__init__.py'
>>> print(json.dumps(self._vcr_request._to_dict(), default=str, indent=2))
{
"method": "POST",
"uri": "https://{{ HOST REDACTED }}{{ PATH REDACTED }}?page=0",
"body": "b'{{ SEE ABOVE }}'",
"headers": {
"User-Agent": [
"{{ REDACTED }}"
],
"Accept-Encoding": [
"gzip, deflate, br"
],
"Accept": [
"*/*"
],
"Connection": [
"keep-alive"
],
"Content-Length": [
"4836"
],
"Content-Type": [
"multipart/form-data; boundary=7ac9dc7b70e1c10c8b48844f6dd76995"
],
"Authorization": [
"Bearer {{ REDACTED }}"
]
}
} I'm also on the latest version: sammorgan$ python -c "import vcr; print(vcr.__version__)"
5.1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This sequence
vcrpy/vcr/filters.py
Lines 110 to 116 in f3f6608
assumes that anything that isn't a BytesIO or dict or with content-type json that is splittable by
b"="
can be UTF-8 decoded. But any random unlucky binary data is likely to have ab"="
somewhere in it, and, if passed in as a raw byte array instead of a BytesIO, it then chokes that decode with'utf-8' codec can't decode...blah blah blah
if the user has definedfilter_post_data_parameters
for their recorder.The BytesIO check in
vcrpy/vcr/filters.py
Line 86 in f3f6608
The text was updated successfully, but these errors were encountered: