{"action":"created","issue":{"url":"https://api.github.com/repos/kevin1024/vcrpy/issues/255","repository_url":"https://api.github.com/repos/kevin1024/vcrpy","labels_url":"https://api.github.com/repos/kevin1024/vcrpy/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/kevin1024/vcrpy/issues/255/comments","events_url":"https://api.github.com/repos/kevin1024/vcrpy/issues/255/events","html_url":"https://github.com/kevin1024/vcrpy/issues/255","id":155101427,"number":255,"title":"AttributeError: 'NoneType' object has no attribute 'decode' when 'body' in match_on, fixed with 'raw_body'","user":{"login":"jhh3000","id":10123077,"avatar_url":"https://avatars.githubusercontent.com/u/10123077?v=3","gravatar_id":"","url":"https://api.github.com/users/jhh3000","html_url":"https://github.com/jhh3000","followers_url":"https://api.github.com/users/jhh3000/followers","following_url":"https://api.github.com/users/jhh3000/following{/other_user}","gists_url":"https://api.github.com/users/jhh3000/gists{/gist_id}","starred_url":"https://api.github.com/users/jhh3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhh3000/subscriptions","organizations_url":"https://api.github.com/users/jhh3000/orgs","repos_url":"https://api.github.com/users/jhh3000/repos","events_url":"https://api.github.com/users/jhh3000/events{/privacy}","received_events_url":"https://api.github.com/users/jhh3000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-05-16T19:23:00Z","updated_at":"2016-07-16T20:01:14Z","closed_at":null,"body":"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):\r\n\r\n```bash\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py\", line 473, in get\r\n    return self.request('GET', url, **kwargs)\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py\", line 461, in request\r\n    resp = self.send(prep, **send_kwargs)\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.py\", line 573, in send\r\n    r = adapter.send(request, **kwargs)\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/adapters.py\", line 370, in send\r\n    timeout=timeout\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py\", line 518, in urlopen\r\n    body=body, headers=headers)\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py\", line 353, in _make_request\r\n    httplib_response = conn.getresponse(buffering=True)\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/stubs/__init__.py\", line 219, in getresponse\r\n    if self.cassette.can_play_response_for(self._vcr_request):\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py\", line 232, in can_play_response_for\r\n    return request and request in self and \\\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py\", line 303, in __contains__\r\n    for index, response in self._responses(request):\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/cassette.py\", line 227, in _responses\r\n    if requests_match(request, stored_request, self._match_on):\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py\", line 97, in requests_match\r\n    matches = [(m(r1, r2), m) for m in matchers]\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py\", line 80, in body\r\n    return transformer(read_body(r1)) == transformer(read_body(r2))\r\n  File \"/home/vagrant/venv/local/lib/python2.7/site-packages/vcr/matchers.py\", line 52, in _transform_json\r\n    return json.loads(body.decode('utf-8'))\r\nAttributeError: 'NoneType' object has no attribute 'decode'\r\n```"},"comment":{"url":"https://api.github.com/repos/kevin1024/vcrpy/issues/comments/233148296","html_url":"https://github.com/kevin1024/vcrpy/issues/255#issuecomment-233148296","issue_url":"https://api.github.com/repos/kevin1024/vcrpy/issues/255","id":233148296,"user":{"login":"maroux","id":3266934,"avatar_url":"https://avatars.githubusercontent.com/u/3266934?v=3","gravatar_id":"","url":"https://api.github.com/users/maroux","html_url":"https://github.com/maroux","followers_url":"https://api.github.com/users/maroux/followers","following_url":"https://api.github.com/users/maroux/following{/other_user}","gists_url":"https://api.github.com/users/maroux/gists{/gist_id}","starred_url":"https://api.github.com/users/maroux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maroux/subscriptions","organizations_url":"https://api.github.com/users/maroux/orgs","repos_url":"https://api.github.com/users/maroux/repos","events_url":"https://api.github.com/users/maroux/events{/privacy}","received_events_url":"https://api.github.com/users/maroux/received_events","type":"User","site_admin":false},"created_at":"2016-07-16T20:01:14Z","updated_at":"2016-07-16T20:01:14Z","body":"@jhh3000 I ran into the same problem - it looks like your cassette may be problematic. For me, I had a request like this:\r\n```\r\n- request:\r\n    body: null\r\n    headers:\r\n      Content-Length: ['41']\r\n      Content-Type: [application/json]\r\n    method: GET\r\n```\r\nThe `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."}}
{"actor":{"display_login":"maroux"}}