[ 
https://issues.apache.org/jira/browse/COUCHDB-3171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15640187#comment-15640187
 ] 

TIMOTHY MCKERNAN commented on COUCHDB-3171:
-------------------------------------------

For me, if I don't add a query object to the reply then the parameters are 
reconstructed properly. I only experienced the above problem when I need to 
edit the parameters and return them in a new query object.

> Rewrite function creates invalid query string (missing ampersands)
> ------------------------------------------------------------------
>
>                 Key: COUCHDB-3171
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-3171
>             Project: CouchDB
>          Issue Type: Bug
>            Reporter: Tyler Roberts
>
> Having a rewrite function in the design document does not properly 
> reconstruct the query string on rewrite. All params are smashed together with 
> no ampersand (&) separating them which will cause {{badarg}} or other 
> exceptions.
> Basic Example:
> {{/_changes?timeout=25000&style=all_docs&heartbeat=10000&since=0&limit=100}}
> Will get rewritten as: 
> {{/_changes?timeout=25000style=all_docsheartbeat=10000since=0limit=100}}
> This issue will occur even if rewrite function does not return new query 
> object.
> CouchDB 2.0.0 MacOS install.
> {code}
> [vhosts]
> health-app.local:5984 = /health-app/_design/health-app/_rewrite
>  
> // rewrite function
> function (req){
>   return {path: '../../_all_docs', query: {"limit": "3", "offset": "1"}};
> }
> // HTTP Response for http://health-app.local:5984/api/something
> {
> error: "query_parse_error",
> reason: "Invalid value for integer: "3offset=1""
> }
> {code}
> Full Debug Logs:
> {noformat}
> [debug] 2016-09-30T00:04:31.844627Z couchdb@localhost <0.12486.1> 196c040436 
> Vhost Target: '"/health-app/_design/health-app/_rewrite/api/something"' 
> ["ddoc","_design/health-app",["rewrites"],[{"method":"GET","requested_path":["api","something"],"path":["health-app","_design","health-app","_rewrite","api","something"],"raw_path":"/health-app/_design/health-app/_rewrite/api/something","query":{},"headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Encoding":"gzip,
>  deflate, 
> sdch","Accept-Language":"en-US,en;q=0.8","Cache-Control":"max-age=0","Connection":"keep-alive","Dnt":"1","Host":"health-app.local:5984","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0
>  (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) 
> Chrome/53.0.2785.116 
> Safari/537.36","x-couchdb-vhost-path":"/api/something"},"body":"undefined","peer":"127.0.0.1","cookie":{},"userCtx":{"db":"health-app","name":null,"roles":[]},"secObj":{}}]]
> [debug] 2016-09-30T00:04:31.848279Z couchdb@localhost <0.13116.0> -------- OS 
> Process #Port<0.6979> Output :: 
> ["ok",{"path":"../../_all_docs","query":{"limit":"3","offset":"1"}}]
> [debug] 2016-09-30T00:04:31.848487Z couchdb@localhost <0.12486.1> 88b5f7bb6f 
> rewrite to "/health-app/_all_docs?limit=3offset=1"
> [notice] 2016-09-30T00:04:31.849788Z couchdb@localhost <0.12486.1> 17ad726f62 
> health-app.local:5984 127.0.0.1 undefined GET 
> /health-app/_all_docs?limit=3offset=1 400 ok 1
> [notice] 2016-09-30T00:04:31.849885Z couchdb@localhost <0.12486.1> 17ad726f62 
> health-app.local:5984 127.0.0.1 undefined GET 
> /health-app/_design/health-app/_rewrite/api/something 400 ok 5
> [notice] 2016-09-30T00:04:33.544599Z couchdb@localhost <0.320.0> -------- 
> chttpd_auth_cache changes listener died database_does_not_exist at 
> mem3_shards:load_shards_from_db/6(line:327) <= 
> mem3_shards:load_shards_from_disk/1(line:315) <= 
> mem3_shards:load_shards_from_disk/2(line:331) <= 
> mem3_shards:for_docid/3(line:87) <= fabric_doc_open:go/3(line:38) <= 
> chttpd_auth_cache:ensure_auth_ddoc_exists/2(line:187) <= 
> chttpd_auth_cache:listen_for_changes/1(line:134)
> [error] 2016-09-30T00:04:33.544668Z couchdb@localhost emulator -------- Error 
> in process <0.15048.1> on node couchdb@localhost with exit value:
> {database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,327}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,315}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,331}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,87}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,38}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,187}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,134}]}]}
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to