I have a list function that can be accessed like this:
_list/characters/characters_by_user?startkey=["org.couchdb.user:rodriguez"]&endkey=["org.couchdb.user:rodriguez", {}]
I’m attempting to rewrite the URL so you can access it in a friendlier way…
/rodriguez/characters
…by writing this rule:
{from: '/:user/characters', to: '_list/characters/characters_by_user',
query: {
startkey: "[%22org.couchdb.user%3A:user%22]",
endkey: "[%22org.couchdb.user%3A:user%22,%20{}]"
}
}
However, I get this error:
error: "query_parse_error",
reason: "No rows can match your key range, reverse your start_key and end_key or set descending=true"
Why would the query work correctly in the full URL, but not using the rewrite?
Update
I believe this may be a bug with the way CouchDB handles the encoded colon (%3A). I’m awaiting a response from the mailing list and will update this question accordingly.
I found that checking CouchDB’s logs proved to be the best way to troubleshoot how URLs were being rewritten. Unfortunately, the issue I submitted to the CouchDB mailing list has yet to be replied to.
As a workaround, I’ve emitted the user’s name without fully-qualifying it, which suits my purpose: