summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2019-11-26 12:11:54 +0200
committergarren smith <garren.smith@gmail.com>2019-11-26 16:46:15 +0200
commit6d432a920e94f7de1de69efe963a4abbf8e5ac33 (patch)
tree20b5f36379b14e91b798ae060662232fe197fdd5
parent411616059abd4178d1e13689eda11d7cb975a407 (diff)
downloadcouchdb-6d432a920e94f7de1de69efe963a4abbf8e5ac33.tar.gz
Return 400 error for missing partition key
Return a 400 for urls /partitiondb/_partition with no partition key Fixes #2332
-rw-r--r--src/chttpd/src/chttpd_db.erl3
-rw-r--r--test/elixir/test/partition_crud_test.exs9
2 files changed, 12 insertions, 0 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 970495f0a..89351cc6e 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 aea8069f7..7add46014 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"