You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/08/12 19:46:45 UTC

[jira] [Commented] (COUCHDB-2772) Return HTTP 400 rather than HTTP 500 on view compilation error

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

ASF GitHub Bot commented on COUCHDB-2772:
-----------------------------------------

GitHub user mikewallace1979 opened a pull request:

    https://github.com/apache/couchdb-couch/pull/86

    Return bad_request on view compilation error

    A request adding a non-compiling view was previously generating
    an HTTP 500 response. However, because the request is supplying an
    invalid view an HTTP 400 bad request response would be appropriate
    here. It would also make things clearer to the client that the
    fault lies within the request rather than the server.
    
    This commit updates the error returned on view compilation error
    to a {bad_request, compilation_error, Msg}. This will be converted
    into an HTTP 400 response by chttpd.
    
    Closes COUCHDB-2772

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mikewallace1979/couchdb-couch 2772-http-400-on-view-compilation-error

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch/pull/86.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #86
    
----
commit 629e1553127a49f5891cd373eba4139ee54b11eb
Author: Mike Wallace <mi...@apache.org>
Date:   2015-08-12T17:38:19Z

    Return bad_request on view compilation error
    
    A request adding a non-compiling view was previously generating
    an HTTP 500 response. However, because the request is supplying an
    invalid view an HTTP 400 bad request response would be appropriate
    here. It would also make things clearer to the client that the
    fault lies within the request rather than the server.
    
    This commit updates the error returned on view compilation error
    to a {bad_request, compilation_error, Msg}. This will be converted
    into an HTTP 400 response by chttpd.
    
    Closes COUCHDB-2772

----


> 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
>
> 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)