histrio/py-couchdb

Saving a design document fails due to malformed URL

internaut opened this issue · 5 comments

I was trying to upload a simple design document with the document ID "_design/browse". It failed with

  File "/usr/local/lib/python3.4/dist-packages/pycouchdb/client.py", line 225, in save
    if "rev" in result and result["rev"] is not None:
TypeError: argument of type 'NoneType' is not iterable

Saving other documents (non-design documents) works without problems. Deleting, creating a DB, etc. works too, so it is not a problem related to permissions (I'm connected as admin user).

After further investigation, I found out that the response from the server is a 404 document not found error. I further found out that it was trying to save the document to the URL http://127.0.0.1:8080/couchdb/bsdp_v2/_design%2Fbrowse which I guess reveals the error. I think it should be http://127.0.0.1:8080/couchdb/bsdp_v2/_design/browse, so slashes shouldn't be URL-encoded (at least not in the case of design documents.

I'm using pycouchdb 1.12.

Hi, Markus!
I can't reproduce this error. https://bpaste.net/show/e03aeefe39df
Would you please provide more detailed info for the bug?

Hi histrio,
I think the problem lies with my server URL. My CouchDB instance runs through Apache at "http://127.0.0.1:8080/couchdb/". Mind the "/couchdb/". I ran your script from bpaste.net and only changed the following line: server = pycouchdb.Server('http://admin:admin@127.0.0.1:8080/couchdb/') and I get exactly the same error as described in my initial post. As I said, I think it is because the slash in "_design/browse" gets URL-encoded and this probably because pycouchdb has a problem with my CouchDB instance running at "... /couchdb/". If you change your CouchDB configuration and hence your server URL, I think you will be able to reproduce the error.

Special for you I have deployed new CouchDB instance :)
Try it yourself https://bpaste.net/show/07005b7366fe
And yes I saw in nginx's logs that malformed url, but it works fine.

I just noticed that you're using python3, but I tested it on python2

Hi histrio,
thanks for your work setting this up. Unfortunately, it doesn't really help me that it works for your setup. On my setup (Apache + CouchDB 1.2.0) it doesn't, though, and this is because of the malformed URL I'm quite sure. I don't think it's a Python2/3 issue.

HI @internaut,
Sorry for late anwser. Due the the #54 (if all is well with test) this issue can be resolved with removing escaping at all.