[ 
https://issues.apache.org/jira/browse/COUCHDB-2772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Newson resolved COUCHDB-2772.
------------------------------------
       Resolution: Fixed
    Fix Version/s: 2.0.0

> Return HTTP 400 rather than HTTP 500 on view compilation error
> --------------------------------------------------------------
>
>                 Key: COUCHDB-2772
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2772
>             Project: CouchDB
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: Database Core
>            Reporter: Mike Wallace
>             Fix For: 2.0.0
>
>
> Attempting to upload a view that doesn't compile will result in an HTTP 500 
> internal server error response:
> $ curl -X PUT http://localhost:5984/ohai
> {"ok":true}
> $ curl -X PUT http://localhost:5984/ohai/_design/foo -d 
> '{"views":{"doge":{"map":"function(doc) { emit(doc.id, 1); };", "reduce": 
> "wat"}}}'
> * Connected to localhost (127.0.0.1) port 5984 (#0)
> * Server auth using Basic with user 'admin'
> > PUT /ohai/_design/foo HTTP/1.1
> > Authorization: Basic YWRtaW46aHNq
> > User-Agent: curl/7.37.1
> > Host: localhost:5984
> > Accept: */*
> > Content-Length: 81
> > Content-Type: application/x-www-form-urlencoded
> > 
> * upload completely sent off: 81 out of 81 bytes
> < HTTP/1.1 500 Internal Server Error
> < X-CouchDB-Body-Time: 0
> < X-Couch-Request-ID: e844aa0311
> * Server CouchDB/0bf8917 (Erlang OTP/17) is not blacklisted
> < Server: CouchDB/0bf8917 (Erlang OTP/17)
> < Date: Wed, 12 Aug 2015 14:26:57 GMT
> < Content-Type: text/plain; charset=utf-8
> < Content-Length: 149
> < Cache-Control: must-revalidate
> < 
> {"error":"compilation_error","reason":"Compilation of the reduce function in 
> the 'doge' view failed: Expression does not eval to a function. (wat)"}
> Because the request is supplying an invalid view an HTTP 400 bad request 
> response would be appropriate here, and would make things clearer to the 
> client that the fault lies within the request rather than the server.



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

Reply via email to