PUTting "_local" docs via the Sync Gateway CouchDB-like REST api

100 views
Skip to first unread message

Steven Barlow

unread,
May 2, 2014, 1:44:35 AM5/2/14
to mobile-c...@googlegroups.com
I'm trying to migrate some of my code from CouchDB to Couchbase. I'm using the Sync Gateway REST api to consume some capability via a CouchDB-like api (In part, because my code is dependant on _revs, and change streams).

I've managed to migrate most of the code, and it's looking good, with one exception:

Attempting to PUT a document with a "_local/" prefixed id fails with an 'unknown URL' error. I can insert documents with a "_local/" id via the Couchbase admin console.

Anybody got any thoughts on this?

Jens Alfke

unread,
May 2, 2014, 9:57:49 AM5/2/14
to mobile-c...@googlegroups.com
On May 1, 2014, at 10:44 PM, Steven Barlow <stem...@gmail.com> wrote:

Attempting to PUT a document with a "_local/" prefixed id fails with an 'unknown URL' error.

That should work (and it’s used by the replicator, so I’m pretty confident it does work.) Can you show me an actual request/response, like a ‘curl’ command or a TCP dump?

—Jens

Steven Barlow

unread,
May 2, 2014, 8:28:17 PM5/2/14
to mobile-c...@googlegroups.com
OK, so I think I got to the bottom of this, the issue is actually with encoded slashes in the path (not the underscore prefix per-se). Thus:

1) curl -X PUT http://localhost:4985/tests/_local/tester --data '{"foo": "bar"}' -H "content-type:application/json"
2) curl -X PUT http://localhost:4985/tests/_local%2Ftester --data '{"foo": "bar"}' -H "content-type:application/json"

#1 works in Sync Gateway, whereas #2 does not (returns a 404 error). Both forms of the above request work in CouchDB. The same is true of GET calls too by the way.

Not sure where you think that leaves the issue Jens. Is it something you'd like to fix in Sync Gateway, or do you believe it's an acceptable quirk? I can raise an issue if you think it's worth addressing.

For me it's a bit of a pain, because I'm using a third party lib for my CouchDB REST calls (dscape/nano), and this URL encoding is governed by that component, so I may (or may not, I've not dug into it yet) have to fork that to fix the problems that I'm seeing.

Cheers,
Steven

Steven Barlow

unread,
May 2, 2014, 8:33:42 PM5/2/14
to mobile-c...@googlegroups.com
So I found this https://github.com/couchbase/sync_gateway/issues/204, which is closed as fixed. Is this a regression, or are the issues not the same?


Jens Alfke

unread,
May 2, 2014, 9:39:52 PM5/2/14
to mobile-c...@googlegroups.com

On May 2, 2014, at 5:33 PM, Steven Barlow <stem...@gmail.com> wrote:

So I found this https://github.com/couchbase/sync_gateway/issues/204, which is closed as fixed. Is this a regression, or are the issues not the same?

They’re definitely related, but not the same. I think the internal URL routing in the gateway isn’t handling _local%2F correctly because it doesn’t see the _local part as a separate path component. Could you file a bug report, please?

—Jens

Steven Barlow

unread,
May 4, 2014, 7:49:36 PM5/4/14
to mobile-c...@googlegroups.com
Jens,


Cheers,
Steven
Reply all
Reply to author
Forward
0 new messages