[
https://issues.apache.org/jira/browse/COUCHDB-2765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14650547#comment-14650547
]
Alexander Shorin commented on COUCHDB-2765:
-------------------------------------------
This happens because of changes feed streaming nature: CouchDB starts response
without trigger any checks nor ensure that filter is valid because all this
work may be not needed to do at all. It's possible to check if view is valid
before start response, but it wouldn't save you from invalid JSON with HTTP 200
response if view will generate some error in the middle of stream. Same is true
for any other filter.
So here could be two solutions:
1. Emit errors as the result items instead of aborting the connection - this
will keep JSON to be valid and provide feedback for the internal errors.
2. Because such behaviour existed since the very first CouchDB releases with
the filters, teach clients to handle unexpectable connection abort and throw
the error about. Users should check the CouchDB logs in order to find their
mistake in the filter definition.
> CouchDB sends 200 and invalid JSON if _changes view filter is invalid
> ----------------------------------------------------------------------
>
> Key: COUCHDB-2765
> URL: https://issues.apache.org/jira/browse/COUCHDB-2765
> Project: CouchDB
> Issue Type: Bug
> Security Level: public(Regular issues)
> Components: HTTP Interface
> Reporter: Nolan Lawson
>
> If you provide a {{view}} with {{filter=_view}} in {{_changes}} and the
> referenced {{view}} is a design doc with no {{map}} function, then the
> database returns a 200 with invalid JSON.
> cURL to reproduce:
> {code}
> curl 'http://127.0.0.1:5984/testdb/' -X DELETE -H 'Content-Type:
> application/json' -H 'Accept: application/json'
> curl 'http://127.0.0.1:5984/testdb/' -X PUT -H 'Content-Type:
> application/json' -H 'Accept: application/json'
> curl 'http://127.0.0.1:5984/testdb/_design/name' -X PUT -H 'Content-Type:
> application/json' -H 'Accept: application/json' --data-binary
> '{"_id":"_design/name","views":{"name":{"empty":"sad face"}}}'
> curl
> 'http://127.0.0.1:5984/testdb/_changes?timeout=25000&feed=longpoll&filter=_view&view=name%2Fname&since=0&limit=25&_nonce=1438464395669'
> -H 'Accept: application/json'
> {code}
> Result:
> {code}
> {"ok":true}
> {"ok":true}
> {"ok":true,"id":"_design/name","rev":"1-214291b1f3879ad7a5f408d3e1edb53b"}
> {"results":[
> curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding
> {code}
> The final response from CouchDB is this invalid JSON:
> {code}
> {"results":[
> An error has occurred: {"bytesParsed":0,"code":"HPE_INVALID_CHUNK_SIZE"}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)