From 262944f0244c86c5fdb794ebe538fb916ff5415c Mon Sep 17 00:00:00 2001 From: Mayya Sharipova Date: Thu, 3 Nov 2016 19:46:05 -0400 Subject: [PATCH] HTTP code 500 instead of 400 for invalid key during document creation The wrong status code is returned when creating or updating a document with an invalid key. Returns: {u'reason': u'Bad special document member: _invalid_key', u'error': u'doc_validation'} HTTPError: 500 Server Error: Internal Server Error Expected: 400 Bad Request error COUCHDB-3222 --- src/chttpd.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chttpd.erl b/src/chttpd.erl index 33e7876..1723ebc 100644 --- a/src/chttpd.erl +++ b/src/chttpd.erl @@ -885,6 +885,8 @@ error_info({_DocID,{illegal_docid,DocID}}) -> error_info({error, {database_name_too_long, DbName}}) -> {400, <<"database_name_too_long">>, <<"At least one path segment of `", DbName/binary, "` is too long.">>}; +error_info({doc_validation, Reason}) -> + {400, <<"doc_validation">>, Reason}; error_info({missing_stub, Reason}) -> {412, <<"missing_stub">>, Reason}; error_info(request_entity_too_large) ->