couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject chttpd commit: updated refs/heads/master to 31c15c7
Date Thu, 17 Sep 2015 17:32:50 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master b518e2a33 -> 31c15c70d


POST to /{db}/_all_docs with invalid keys should return 400

Now they return 500. Since there is nothing wrong on the 500,
400 is more appropriate.

For example, turns requests like these:

http -a adm:pass POST http://127.0.0.1:15984/db1/_all_docs  keys:='["1",2]'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "2",
    "reason": "{illegal_docid,2}"
}

Into:

http -a adm:pass POST http://127.0.0.1:15984/db1/_all_docs  keys:='["1",2]'
HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "error": "illegal_docid",
    "reason": 2
}

COUCHDB-2815


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/31c15c70
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/31c15c70
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/31c15c70

Branch: refs/heads/master
Commit: 31c15c70d1c1885ccf1cf6f03f18d0b079d664d9
Parents: b518e2a
Author: Nick Vatamaniuc <vatamane@gmail.com>
Authored: Wed Sep 16 16:48:20 2015 -0400
Committer: Nick Vatamaniuc <vatamane@gmail.com>
Committed: Wed Sep 16 16:48:20 2015 -0400

----------------------------------------------------------------------
 src/chttpd.erl                   | 2 ++
 test/chttpd_error_info_tests.erl | 4 ++++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/31c15c70/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index a5baa27..81552ca 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -818,6 +818,8 @@ error_info({error, {illegal_database_name, Name}}) ->
         "digits (0-9), and any of the characters _, $, (, ), +, -, and / ",
         "are allowed. Must begin with a letter.">>,
     {400, <<"illegal_database_name">>, Message};
+error_info({_DocID,{illegal_docid,DocID}}) ->
+    {400, <<"illegal_docid">>,DocID};
 error_info({missing_stub, Reason}) ->
     {412, <<"missing_stub">>, Reason};
 error_info(request_entity_too_large) ->

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/31c15c70/test/chttpd_error_info_tests.erl
----------------------------------------------------------------------
diff --git a/test/chttpd_error_info_tests.erl b/test/chttpd_error_info_tests.erl
index cb0a58a..acc4b5e 100644
--- a/test/chttpd_error_info_tests.erl
+++ b/test/chttpd_error_info_tests.erl
@@ -116,6 +116,10 @@ error_info_test() ->
                " the characters _, $, (, ), +, -, and / are allowed."
                " Must begin with a letter.">>}
         },
+	{
+            {Error, {illegal_docid,1}},
+            {400, <<"illegal_docid">>, 1}
+	},
         {
             {missing_stub, Reason},
             {412, <<"missing_stub">>, Reason}


Mime
View raw message