Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22F93104A2 for ; Tue, 18 Mar 2014 10:42:46 +0000 (UTC) Received: (qmail 8539 invoked by uid 500); 18 Mar 2014 10:42:45 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 7997 invoked by uid 500); 18 Mar 2014 10:42:44 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 7984 invoked by uid 99); 18 Mar 2014 10:42:42 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 10:42:42 +0000 Date: Tue, 18 Mar 2014 10:42:42 +0000 (UTC) From: "richard delorenzi (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (COUCHDB-2204) rewrite of lists fail when not for key MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-2204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] richard delorenzi updated COUCHDB-2204: --------------------------------------- Description: I have the following fragment in rewrite.json, {code:javascript|title=this rewrite.json does not work} { "from": "server_lib/:~name", "to": "_list/sub/design", "query": { "path": ["lib", ":~name" ] } } {code} when I try to fetch the page with {code: title=http get} curl -s -D /dev/stderr -H "Accept: application/json" 'http://localhost:5984/q-couch-test/_design/couch-experiment/_rewrite/server_lib/myLib' {code} I get this error {code: title=error} log error: [Tue, 18 Mar 2014 09:54:31 GMT] [info] [<0.5037.0>] Stacktrace: [{erlang,iolist_to_binary, [[<<"myLib">>,{[]}]], []}, {couch_httpd_rewrite, '-maybe_encode_bindings/1-fun-0-',2, [{file,"couch_httpd_rewrite.erl"}, {line,453}]}, {lists,foldl,3, [{file,"lists.erl"},{line,1197}]}, {couch_httpd_rewrite,handle_rewrite_req,3, [{file,"couch_httpd_rewrite.erl"}, {line,147}]}, {couch_httpd_db,do_db_req,2, [{file,"couch_httpd_db.erl"},{line,230}]}, {couch_httpd,handle_request_int,5, [{file,"couch_httpd.erl"},{line,317}]}, {mochiweb_http,headers,5, [{file,"mochiweb_http.erl"},{line,136}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}] {code} The bug seems to be in couch_httpd_rewrite.erl in maybe_json. It treats keys specially, so we can represent keys as lists but not other query strings. e.g. this rewrite fragment works {code: javascript|title=working rewrite.json example} { "from": "view/by_name/:~type", "to": "_view/all-by-name", "query": { "startkey": [ ":~type", null ], "endkey": [ ":~type", {} ] } } {code} was: I have the following fragment in rewrite.json, {code:javascript|title=this rewrite.json does not work} { "from": "server_lib/:~name", "to": "_list/sub/design", "query": { "path": ["lib", ":~name" ], "include_docs": "true" } } {code} when I try to fetch the page with {code: title=http get} curl -s -D /dev/stderr -H "Accept: application/json" 'http://localhost:5984/q-couch-test/_design/couch-experiment/_rewrite/server_lib/myLib' {code} I get this error {code: title=error} log error: [Tue, 18 Mar 2014 09:54:31 GMT] [info] [<0.5037.0>] Stacktrace: [{erlang,iolist_to_binary, [[<<"myLib">>,{[]}]], []}, {couch_httpd_rewrite, '-maybe_encode_bindings/1-fun-0-',2, [{file,"couch_httpd_rewrite.erl"}, {line,453}]}, {lists,foldl,3, [{file,"lists.erl"},{line,1197}]}, {couch_httpd_rewrite,handle_rewrite_req,3, [{file,"couch_httpd_rewrite.erl"}, {line,147}]}, {couch_httpd_db,do_db_req,2, [{file,"couch_httpd_db.erl"},{line,230}]}, {couch_httpd,handle_request_int,5, [{file,"couch_httpd.erl"},{line,317}]}, {mochiweb_http,headers,5, [{file,"mochiweb_http.erl"},{line,136}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}] {code} The bug seems to be in couch_httpd_rewrite.erl in maybe_json. It treats keys specially, so we can represent keys as lists but not other query strings. e.g. this rewrite fragment works {code: javascript|title=working rewrite.json example} { "from": "view/by_name/:~type", "to": "_view/all-by-name", "query": { "startkey": [ ":~type", null ], "endkey": [ ":~type", {} ] } } {code} > rewrite of lists fail when not for key > -------------------------------------- > > Key: COUCHDB-2204 > URL: https://issues.apache.org/jira/browse/COUCHDB-2204 > Project: CouchDB > Issue Type: Bug > Security Level: public(Regular issues) > Components: HTTP Interface > Reporter: richard delorenzi > > I have the following fragment in rewrite.json, > {code:javascript|title=this rewrite.json does not work} > { > "from": "server_lib/:~name", > "to": "_list/sub/design", > "query": { > "path": ["lib", ":~name" ] > } > } > {code} > when I try to fetch the page with > {code: title=http get} > curl -s -D /dev/stderr -H "Accept: application/json" 'http://localhost:5984/q-couch-test/_design/couch-experiment/_rewrite/server_lib/myLib' > {code} > I get this error > {code: title=error} > log error: > [Tue, 18 Mar 2014 09:54:31 GMT] [info] [<0.5037.0>] Stacktrace: [{erlang,iolist_to_binary, > [[<<"myLib">>,{[]}]], > []}, > {couch_httpd_rewrite, > '-maybe_encode_bindings/1-fun-0-',2, > [{file,"couch_httpd_rewrite.erl"}, > {line,453}]}, > {lists,foldl,3, > [{file,"lists.erl"},{line,1197}]}, > {couch_httpd_rewrite,handle_rewrite_req,3, > [{file,"couch_httpd_rewrite.erl"}, > {line,147}]}, > {couch_httpd_db,do_db_req,2, > [{file,"couch_httpd_db.erl"},{line,230}]}, > {couch_httpd,handle_request_int,5, > [{file,"couch_httpd.erl"},{line,317}]}, > {mochiweb_http,headers,5, > [{file,"mochiweb_http.erl"},{line,136}]}, > {proc_lib,init_p_do_apply,3, > [{file,"proc_lib.erl"},{line,227}]}] > {code} > The bug seems to be in couch_httpd_rewrite.erl in maybe_json. It treats keys specially, so we can represent keys as lists but not other query strings. > e.g. this rewrite fragment works > {code: javascript|title=working rewrite.json example} > { > "from": "view/by_name/:~type", > "to": "_view/all-by-name", > "query": { > "startkey": [ ":~type", null ], > "endkey": [ ":~type", {} ] > } > } > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)