You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/09/22 21:19:53 UTC
couch commit: updated refs/heads/master to 8bbfba7
Repository: couchdb-couch
Updated Branches:
refs/heads/master cb58087c9 -> 8bbfba700
Use illegal_docid error for really bad document ids
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8bbfba70
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8bbfba70
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8bbfba70
Branch: refs/heads/master
Commit: 8bbfba7003d4ad3e8d62f1f13147b22e9138c954
Parents: cb58087
Author: Alexander Shorin <kx...@apache.org>
Authored: Thu Sep 17 23:02:28 2015 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Sep 22 22:18:20 2015 +0300
----------------------------------------------------------------------
src/couch_doc.erl | 10 +++++-----
src/couch_httpd.erl | 2 ++
2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8bbfba70/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index cf34094..a982616 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -159,10 +159,10 @@ parse_revs([Rev | Rest]) ->
validate_docid(<<"">>) ->
- throw({bad_request, <<"Document id must not be empty">>});
+ throw({illegal_docid, <<"Document id must not be empty">>});
validate_docid(Id) when is_binary(Id) ->
case couch_util:validate_utf8(Id) of
- false -> throw({bad_request, <<"Document id must be valid UTF-8">>});
+ false -> throw({illegal_docid, <<"Document id must be valid UTF-8">>});
true -> ok
end,
case Id of
@@ -174,14 +174,14 @@ validate_docid(Id) when is_binary(Id) ->
ok;
false ->
throw(
- {bad_request,
- <<"Only reserved document ids may start with underscore.">>})
+ {illegal_docid,
+ <<"Only reserved document ids may start with underscore.">>})
end;
_Else -> ok
end;
validate_docid(Id) ->
couch_log:debug("Document id is not a string: ~p", [Id]),
- throw({bad_request, <<"Document id must be a string">>}).
+ throw({illegal_docid, <<"Document id must be a string">>}).
transfer_fields([], #doc{body=Fields}=Doc) ->
% convert fields back to json object
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8bbfba70/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index db447cb..eeeb934 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -843,6 +843,8 @@ error_info({query_parse_error, Reason}) ->
% Prior art for md5 mismatch resulting in a 400 is from AWS S3
error_info(md5_mismatch) ->
{400, <<"content_md5_mismatch">>, <<"Possible message corruption.">>};
+error_info({illegal_docid, Reason}) ->
+ {400, <<"illegal_docid">>, Reason};
error_info(not_found) ->
{404, <<"not_found">>, <<"missing">>};
error_info({not_found, Reason}) ->