Giter Club home page Giter Club logo

Comments (15)

djc avatar djc commented on July 26, 2024

That certainly sounds plausible. Can you rewrite your test case into a unit test like the ones in couchdb.tests, or at least something I can execute stand-alone?

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Hmm I've written a unit test but it passes, which is interesting. I'll run it against the version of the library I'm using, and if it fails there then I guess I'm late to the party and I'll upgrade to 1.1. It's probably worth noting that I originally encountered this error while using the library to talk to cloudant, not vanilla couchdb, in which case it's possible it's their fault. I'll submit a pull request with my unit test anyway; can't hurt to have regression testing.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Passes when based onto 75e42dc, which I believe is the commit for the 1.0 release, so very possibly this is a problem which only happens with cloudant (which, naturally, I don't expect you to support). I'll try to reproduce with my original code running against couchdb instead of cloudant.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Okay, I've run my original code against couchdb instead of cloudant and it worked. I blame cloudant. I'll leave this open in case you want to look into making it work for cloudant, too, but since one seems to require urlencoding and the other doesn't, there may not be a single solution to suit both, which is a shame.

from couchdb-python.

djc avatar djc commented on July 26, 2024

I'd like CouchDB-Python to support Cloudant, but obviously not at any complexity cost. Let me know how you fare with Cloudant, I thought they mostly use the same code base and even if not, they probably want to stay compatible.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

They're nearly 100% API-compliant, but occasionally that "nearly" bites me. My guess is couch takes the remainder of the path after it sees an update handler URL prefix and treats the rest as a doc ID, whereas cloudant matches the whole path against its router and expects the doc ID to be a urlencoded component. I'll do some experimentation; it may be that couch will accept it either url-encoded or not, whereas cloudant forces you to urlencode it, in which case the best-of-both would be to urlencode it regardless.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

I modified the unit test I wrote to also try with the doc ID urlencoded, but alas it fails because it looks for a doc with a literal %2F in it in regular couchdb if I do that. Doesn't look like there's a good solution to fit both.

from couchdb-python.

djc avatar djc commented on July 26, 2024

That's too bad. 😞 Did you get any further feedback from the Cloudant team about this stuff?

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Haven't spoken to them about it yet; I'll raise a ticket with them when I get chance. It'd be nice to know why they decided to change this, at least.

from couchdb-python.

elistevens avatar elistevens commented on July 26, 2024

I'd also check and see what the behavior is with couchdb 2.0; that's
supposed to be much closer to cloudant's stuff.

Eli

On Tue, Nov 1, 2016 at 8:34 AM, Rob Moore [email protected] wrote:

Haven't spoken to them about it yet; I'll raise a ticket with them when I
get chance. It'd be nice to know why they decided to change this, at least.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#309 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIbIJiCCOm9aZS0om4OF3au_I-Og793ks5q51wQgaJpZM4KjOw6
.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Actually I did run it against 2.0 earlier but most of the tests failed because it refused to allow temporary views:

...
======================================================================
ERROR: test_multiple_rows (__main__.CouchTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "couchdb/tests/couch_tests.py", line 127, in test_multiple_rows
    results = list(self.db.query(query))
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1260, in __iter__
    return iter(self.rows)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1280, in rows
    self._fetch()
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1266, in _fetch
    data = self.view._exec(self.options)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1166, in _exec
    }, **_encode_view_options(options))
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 574, in post_json
    **params)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 593, in _request_json
    headers=headers, **params)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 589, in _request
    credentials=self.credentials)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 421, in request
    raise Forbidden(error)
Forbidden: (u'forbidden', u'Temporary views are not supported in CouchDB')

======================================================================
ERROR: test_update_with_unsafe_doc_ids (__main__.CouchTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "couchdb/tests/couch_tests.py", line 223, in test_update_with_unsafe_doc_ids
    _test_response(urllib.quote(doc_id, safe=''))
  File "couchdb/tests/couch_tests.py", line 209, in _test_response
    docid=doc_id
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1024, in update_doc
    _, headers, body = func(**options)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 564, in put
    return self._request('PUT', path, body=body, headers=headers, **params)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 589, in _request
    credentials=self.credentials)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 429, in request
    raise ServerError((status, error))
ServerError: (500, (u'render_error', u'function raised error: (new TypeError("doc is null", "updates.test", 3)) \nstacktrace: (null,[object Object])@updates.test:3\nrunUpdate(function (doc, req) {doc.test = "passed";return [doc, "ok"];},[object Object],[object Array])@./share/server/main.js:970\n(function (doc, req) {doc.test = "passed";return [doc, "ok"];},[object Object],[object Array])@./share/server/main.js:1061\n("_design/test_slashes_in_doc_ids",[object Array],[object Array])@./share/server/main.js:1526\n()@./share/server/main.js:1571\n()@./share/server/main.js:1592\n@./share/server/main.js:1\n'))

======================================================================
ERROR: test_utf8_encoding (__main__.CouchTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "couchdb/tests/couch_tests.py", line 192, in test_utf8_encoding
    for idx, row in enumerate(self.db.query(query)):
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1260, in __iter__
    return iter(self.rows)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1280, in rows
    self._fetch()
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1266, in _fetch
    data = self.view._exec(self.options)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/client.py", line 1166, in _exec
    }, **_encode_view_options(options))
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 574, in post_json
    **params)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 593, in _request_json
    headers=headers, **params)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 589, in _request
    credentials=self.credentials)
  File "/Users/robmo/Code/third-party/couchdb-python/couchdb/http.py", line 421, in request
    raise Forbidden(error)
Forbidden: (u'forbidden', u'Temporary views are not supported in CouchDB')

----------------------------------------------------------------------
Ran 9 tests in 3.585s

FAILED (errors=7)

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

Actually I've just noticed in the output that my test didn't fail for the same reason, though, it failed because it couldn't find the doc (because the encoding was wrong). So it seems encoding the slash still breaks on couch 2.0

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

I've just run into this again (in a completely different language) so I'm raising a support ticket with Cloudant this time; will let you know what they have to say. I've actually discovered it doesn't work in cloudant regardless of whether it's url-encoded; it always says "Invalid path" as if my slash is part of the url structure, so it seems it must be a bug.

from couchdb-python.

giftig avatar giftig commented on July 26, 2024

FTR it took a while but I've heard back from Cloudant engineers and it seems the issue may in fact be in the nginx proxy my company uses to talk to Cloudant, as they say they can't reproduce the issue their end. So it seems the egg may be on my (or my colleague's) face after all.

from couchdb-python.

djc avatar djc commented on July 26, 2024

Ah, those proxies... Always manage to be less transparent than you thought.

from couchdb-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.