You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Brian Candler (JIRA)" <ji...@apache.org> on 2009/04/18 21:48:14 UTC

[jira] Reopened: (COUCHDB-306) Wacky error responses to malformed documents

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

Brian Candler reopened COUCHDB-306:
-----------------------------------


Examples 1, 4 and 5 now give sensible errors in the body, and example 2 gives a 405 Method Not Allowed response (albeit with an empty body). These are fine.

However example 3 still gives its perplexing response:

$ curl http://127.0.0.1:5984/
{"couchdb":"Welcome","version":"0.9.0a766377"}

-- example 3
$ curl -d "{}" -X POST http://127.0.0.1:5984/foo/bar 
{"error":"badmatch","reason":"{\"application/x-www-form-urlencoded\",[]}"}
$ curl -d "{}" -H "Content-Type: application/json" -X POST http://127.0.0.1:5984/foo/bar 
{"error":"badmatch","reason":"{\"application/json\",[]}"}

Both are with a 500 Internal Server Error

I think a 405 would be more appropriate. The error is that the user tried to POST rather than PUT to update an attachment.


> Wacky error responses to malformed documents
> --------------------------------------------
>
>                 Key: COUCHDB-306
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-306
>             Project: CouchDB
>          Issue Type: Improvement
>    Affects Versions: 0.9
>            Reporter: Brian Candler
>            Assignee: Paul Joseph Davis
>            Priority: Minor
>             Fix For: 0.9.1, 0.10
>
>
> Here are some error conditions where CouchDB provides very strange responses.
> ---- Setup ----
> $ curl -X PUT http://127.0.0.1:5984/foo
> {"ok":true}
> ---- example 1 ----
> $ curl -d "[]" -X PUT http://127.0.0.1:5984/foo/bar
> {"error":"bad_request","reason":[68,111,99,117,109,101,110,116,32,109,117,115,116,32,98,101,32,97,32,74,83,79,78,32,111,98,106,101,99,116]}
> ---- example 2 ----
> $ curl -d "[]" -X PUT http://127.0.0.1:5984/foo/_bulk_docs
> -- TCP connection is dropped on the floor, no response (not even HTTP 500 status)
> ---- example 3 ----
> $ curl -d "{}" -X POST http://127.0.0.1:5984/foo/bar
> {"error":"badmatch","reason":"{\"application/x-www-form-urlencoded\",[]}"}
> $ curl -d "{}" -H "Content-Type: application/json" -X POST http://127.0.0.1:5984/foo/bar
> {"error":"badmatch","reason":"{\"application/json\",[]}"}
> ---- example 4 ----
> $ curl -d '[]' -X POST http://127.0.0.1:5984/foo/_all_docs
> {"error":"badmatch","reason":""}
> ---- example 5 ----
> $ curl -d '{"keys":"foo"}' -X POST http://127.0.0.1:5984/foo/_all_docs
> {"error":"unknown_error","reason":"function_clause"}
> Of course, all of these are misuse of the API, but they may be seen by newcomers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.