Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-2737

Upload of invalid ddoc rejected with status 500, should be 400

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None

    Description

      Each of these responses should have a 400 status code - the client made a Bad Request, there's nothing wrong with the server. Looks like the exception we throw in couch_mrview is getting munged at some point.

      curl -i 127.0.0.1:15984/jira537/_design/foo -d '{"views":{"bar":{"map":"function(doc) { emit (null); }", "reduce":"_foobar"}}}' -X PUT
      HTTP/1.1 500 Internal Server Error
      X-CouchDB-Body-Time: 0
      X-Couch-Request-ID: cb8e2081e7
      Server: CouchDB/331f811 (Erlang OTP/R14B01)
      Date: Wed, 01 Jul 2015 14:11:01 GMT
      Content-Type: text/plain; charset=utf-8
      Content-Length: 85
      Cache-Control: must-revalidate
      
      {"error":"invalid_design_doc","reason":"_foobar is not a supported reduce function"}
      
      curl -i 127.0.0.1:15984/jira537/_design/foo -d '{"views":{"bar":{"map":"function(doc) { emit (null); ", "reduce":"_sum"}}}' -X PUT
      HTTP/1.1 500 Internal Server Error
      X-CouchDB-Body-Time: 0
      X-Couch-Request-ID: f61aa5a5c5
      Server: CouchDB/331f811 (Erlang OTP/R14B01)
      Date: Wed, 01 Jul 2015 14:11:24 GMT
      Content-Type: text/plain; charset=utf-8
      Content-Length: 171
      Cache-Control: must-revalidate
      
      {"error":"compilation_error","reason":"Compilation of the map function in the 'bar' view failed: Expression does not eval to a function. (function(doc) { emit (null); )"}
      
      curl -i 127.0.0.1:15984/jira537/_design/foo -d '{"views":{"bar":{"map":"function(doc) { emit (null); }", "reduce":"function(doc) }{"}}}' -X PUT
      HTTP/1.1 500 Internal Server Error
      X-CouchDB-Body-Time: 0
      X-Couch-Request-ID: e4851c6d1d
      Server: CouchDB/331f811 (Erlang OTP/R14B01)
      Date: Wed, 01 Jul 2015 14:11:39 GMT
      Content-Type: text/plain; charset=utf-8
      Content-Length: 161
      Cache-Control: must-revalidate
      
      {"error":"compilation_error","reason":"Compilation of the reduce function in the 'bar' view failed: Expression does not eval to a function. (function(doc) }{)"}
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            kocolosk Adam Kocoloski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: