histrio/py-couchdb

KeyError: 'etag' due to Bad Request v1.12

sandrobusonera opened this issue · 2 comments

Good Morning,

I just received this error:

py2.7.egg/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'etag'

After some investigation I found it was due to a bad request (wrong couchdb url, I forgot to put https instead of http):

(Pdb) resource.__dict__
{'session': <requests.sessions.Session object at 0x104283bd0>, 'base_url': 'XXX'}
(Pdb) resource.head()
(<Response [400]>, None)

This might be due to: if the result is none it returns the bad request and none: https://github.com/histrio/py-couchdb/blob/master/pycouchdb/resource.py#L101

I know that the mistake is mine but would it be more preferable for the system to throw an exception such as Bad Request (in that case at least)? https://github.com/histrio/py-couchdb/blob/master/pycouchdb/exceptions.py#L32

Many thanks

Thanks for bug report! I'll see what I can do.

-----Original Message-----
From: "Sandro Busonera" notifications@github.com
Sent: ‎21/‎08/‎2015 10:35
To: "histrio/py-couchdb" py-couchdb@noreply.github.com
Subject: [py-couchdb] KeyError: 'etag' due to Bad Request v1.12 (#58)

Good Morning,
I just received this error:
py2.7.egg/requests/structures.py", line 54, in getitem
return self._store[key.lower()][1]
KeyError: 'etag'
After some investigation I found it was due to a bad request (wrong couchdb url, I forgot to put https instead of http):
(Pdb) resource.dict
{'session': <requests.sessions.Session object at 0x104283bd0>, 'base_url': 'XXX'}
(Pdb) resource.head()
(<Response [400]>, None)
This might be due to: if the result is none it returns the bad request and none: https://github.com/histrio/py-couchdb/blob/master/pycouchdb/resource.py#L101
I know that the mistake is mine but would it be more preferable for the system to throw an exception such as Bad Request (in that case at least)? https://github.com/histrio/py-couchdb/blob/master/pycouchdb/exceptions.py#L32
Many thanks

Reply to this email directly or view it on GitHub.

not sure if this was ever fixed. closing