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 10:13:01 UTC

[couchdb] branch add-partition-400-error created (now 2867a0f)

This is an automated email from the ASF dual-hosted git repository.

garren pushed a change to branch add-partition-400-error
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 2867a0f  Return 400 error for missing partition key

This branch includes the following new commits:

     new 2867a0f  Return 400 error for missing partition key

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Return 400 error for missing partition key

Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch add-partition-400-error
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2867a0faa4fa1f6383048aeebd15f4c5bdb39978
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"