couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Shorin (JIRA)" <j...@apache.org>
Subject [jira] [Created] (COUCHDB-2333) Should return error instead of closing connection on invalid subquery for multirange view request
Date Fri, 19 Sep 2014 19:57:34 GMT
Alexander Shorin created COUCHDB-2333:
-----------------------------------------

             Summary: Should return error instead of closing connection on invalid subquery
for multirange view request
                 Key: COUCHDB-2333
                 URL: https://issues.apache.org/jira/browse/COUCHDB-2333
             Project: CouchDB
          Issue Type: Bug
      Security Level: public (Regular issues)
          Components: View Server Support
            Reporter: Alexander Shorin


The case: we have a view that produces the following output
{code}
{
    "offset": 0, 
    "rows": [
        {
            "id": "d57078236372da6b4c782bded8000a4b", 
            "key": 1, 
            "value": null
        }, 
        {
            "id": "d57078236372da6b4c782bded8000a4b", 
            "key": 2, 
            "value": null
        }, 
        {
            "id": "d57078236372da6b4c782bded8000a4b", 
            "key": 3, 
            "value": null
        }, 
        {
            "id": "d57078236372da6b4c782bded8000a4b", 
            "key": 4, 
            "value": null
        }, 
        {
            "id": "d57078236372da6b4c782bded8000a4b", 
            "key": 5, 
            "value": null
        }
    ], 
    "total_rows": 5
}
{code}

When the first subquery in multirange view request contains an error CouchDB reports about
it and doesn't process other ranges:

{code}curl -v -XPOST http://localhost:15984/test/_design/test/_view/passed -d '{"queries":[{"startkey":
1, "endkey": null}, {"startkey":4,"endkey":4}]}'{code}

{code}
< HTTP/1.1 400 Bad Request
< X-CouchDB-Body-Time: 0
< X-Couch-Request-ID: f8ae85d8
* Server CouchDB/a7dc712 (Erlang OTP/17) is not blacklisted
< Server: CouchDB/a7dc712 (Erlang OTP/17)
< Date: Fri, 19 Sep 2014 19:50:28 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 133
< Cache-Control: must-revalidate
< 
{"error":"query_parse_error","reason":"No rows can match your key range, reverse your start_key
and end_key or set descending=true"}
{code}

While it was able to process the second subquery, well, it's ok reporting about an error.
However, it doesn't makes clear which subquery is wrong.

If the second subquery is invalid things starts going wrong:
{code}curl -v --raw -XPOST http://localhost:15984/test/_design/test/_view/passed -d '{"queries":[{"startkey":
1, "endkey": 2}, {"startkey":4,"endkey":null}]}'{code}

{code}
< HTTP/1.1 200 OK
< X-CouchDB-Body-Time: 0
< X-Couch-Request-ID: cf5fc515
< Transfer-Encoding: chunked
* Server CouchDB/a7dc712 (Erlang OTP/17) is not blacklisted
< Server: CouchDB/a7dc712 (Erlang OTP/17)
< ETag: d57078236372da6b4c782bded800544c
< Date: Fri, 19 Sep 2014 19:53:45 GMT
< Content-Type: text/plain; charset=utf-8
< Cache-Control: must-revalidate
< 
c
{"results":[
27

{"total_rows":5,"offset":0,"rows":[

3e
{"id":"d57078236372da6b4c782bded8000a4b","key":1,"value":null}
41
,
{"id":"d57078236372da6b4c782bded8000a4b","key":2,"value":null}
4

]}
{code}

CouchDB terminates chunked transfer non graceful (notice --raw flag for curl call) and doesn't
reports about any errors. 

It would be awesome to see something like instead:
{code}
{"results":[
{"total_rows":5,"offset":0,"rows":[
{"id":"d57078236372da6b4c782bded8000a4b","key":1,"value":null},
{"id":"d57078236372da6b4c782bded8000a4b","key":2,"value":null}
]},
{"error":"query_parse_error","reason":"No rows can match your key range, reverse your start_key
and end_key or set descending=true"}
]}
{code}

So client will be able to figure by itself which subquery was wrong to pop the error on top.



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

Mime
View raw message