You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2019/11/26 14:46:26 UTC
[couchdb] branch master updated: Return 400 error for missing
partition key
This is an automated email from the ASF dual-hosted git repository.
garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 6d432a9 Return 400 error for missing partition key
6d432a9 is described below
commit 6d432a920e94f7de1de69efe963a4abbf8e5ac33
Author: Garren Smith <ga...@gmail.com>
AuthorDate: Tue Nov 26 12:11:54 2019 +0200
Return 400 error for missing partition key
Return a 400 for urls /partitiondb/_partition with no partition key
Fixes #2332
---
src/chttpd/src/chttpd_db.erl | 3 +++
test/elixir/test/partition_crud_test.exs | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 970495f..89351cc 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -279,6 +279,9 @@ handle_view_cleanup_req(Req, Db) ->
send_json(Req, 202, {[{ok, true}]}).
+handle_partition_req(#httpd{path_parts=[_,_]}=_Req, _Db) ->
+ throw({bad_request, invalid_partition_req});
+
handle_partition_req(#httpd{method='GET', path_parts=[_,_,PartId]}=Req, Db) ->
couch_partition:validate_partition(PartId),
case couch_db:is_partitioned(Db) of
diff --git a/test/elixir/test/partition_crud_test.exs b/test/elixir/test/partition_crud_test.exs
index aea8069..7add460 100644
--- a/test/elixir/test/partition_crud_test.exs
+++ b/test/elixir/test/partition_crud_test.exs
@@ -95,6 +95,15 @@ defmodule PartitionCrudTest do
end
@tag :with_partitioned_db
+ test "GET to partition returns 400", context do
+ db_name = context[:db_name]
+ url = "/#{db_name}/_partition"
+
+ resp = Couch.get("#{url}")
+ assert resp.status_code == 400
+ end
+
+ @tag :with_partitioned_db
test "POST and _bulk_get document", context do
db_name = context[:db_name]
id = "my-partition-post:doc"