You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using vcr with the following configuration with 'body', there are errors with loading the JSON response -- it could be due to a blank response or blank payload. When I use 'raw_body' it works perfectly. Here's the stack trace (relevant sections):
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 473, in get
return self.request('GET', url, **kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 518, in urlopen
body=body, headers=headers)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
httplib_response = conn.getresponse(buffering=True)
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/stubs/__init__.py", line 219, in getresponse
if self.cassette.can_play_response_for(self._vcr_request):
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py", line 232, in can_play_response_for
return request and request in self and \
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py", line 303, in __contains__
forindex, responsein self._responses(request):
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py", line 227, in _responses
if requests_match(request, stored_request, self._match_on):
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py", line 97, in requests_match
matches = [(m(r1, r2), m) formin matchers]
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py", line 80, in body
return transformer(read_body(r1)) == transformer(read_body(r2))
File "/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py", line 52, in _transform_json
return json.loads(body.decode('utf-8'))
AttributeError: 'NoneType' object has no attribute 'decode'
The text was updated successfully, but these errors were encountered:
The Content-Type being json is the problem here. Removing that header seems to fix the cassette. This was caused by me editing the cassette by hand. Hope this helps.
This is a bug, right? Even though it may be atypical, null is valid json. Either the cassette should be persisting 'null' instead of null, or matchers._transform_json should be able to handle None.
Probably we want to do both? That way, cassettes will be backwards compatible.
When using vcr with the following configuration with 'body', there are errors with loading the JSON response -- it could be due to a blank response or blank payload. When I use 'raw_body' it works perfectly. Here's the stack trace (relevant sections):
The text was updated successfully, but these errors were encountered: