You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ei...@apache.org on 2017/11/02 14:47:31 UTC
[couchdb] branch master updated (2e49d7c -> 01658a0)
This is an automated email from the ASF dual-hosted git repository.
eiri pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
from 2e49d7c Do not always return partial_filter_selector (#951)
new cde2f18 Return error 400 on invalid new_edits value
new 01658a0 Add tests for error on invalid `docs` attribute
The 2 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.
Summary of changes:
src/chttpd/src/chttpd_db.erl | 4 +++-
test/javascript/tests/bulk_docs.js | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].
[couchdb] 02/02: Add tests for error on invalid `docs` attribute
Posted by ei...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
eiri pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 01658a0cc889cffce0ca73b1d06525d708398af8
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Thu Nov 2 10:54:15 2017 -0300
Add tests for error on invalid `docs` attribute
---
test/javascript/tests/bulk_docs.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/test/javascript/tests/bulk_docs.js b/test/javascript/tests/bulk_docs.js
index 9f88e81..ae8a087 100644
--- a/test/javascript/tests/bulk_docs.js
+++ b/test/javascript/tests/bulk_docs.js
@@ -110,6 +110,16 @@ couchTests.bulk_docs = function(debug) {
T(result.error == "bad_request");
T(result.reason == "POST body must include `docs` parameter.");
+ // verify that sending a request with invalid `docs` causes error
+ var req = CouchDB.request("POST", "/" + db_name + "/_bulk_docs", {
+ body: JSON.stringify({"docs": "foo"})
+ });
+
+ T(req.status == 400);
+ result = JSON.parse(req.responseText);
+ T(result.error == "bad_request");
+ T(result.reason == "`docs` parameter must be an array.");
+
// verify that sending a request with invalid `new_edits` causes error
var req = CouchDB.request("POST", "/" + db_name + "/_bulk_docs", {
body: JSON.stringify({"docs": [], "new_edits": 0})
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 01/02: Return error 400 on invalid new_edits value
Posted by ei...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
eiri pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit cde2f180873205aead88a6916595544b599e99bc
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Thu Nov 2 10:51:13 2017 -0300
Return error 400 on invalid new_edits value
End-point `_bulk_docs` crashes if provided
with non-boolean value for `new_edits` parameter.
This patch changes it to return "Bad Request"
error instead.
---
src/chttpd/src/chttpd_db.erl | 4 +++-
test/javascript/tests/bulk_docs.js | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 7e46750..dbbb454 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -451,7 +451,9 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>], user_ctx=Ctx}=Req,
{accepted, Errors} ->
ErrorsJson = lists:map(fun update_doc_result_to_json/1, Errors),
send_json(Req, 202, ErrorsJson)
- end
+ end;
+ _ ->
+ throw({bad_request, <<"`new_edits` parameter must be a boolean.">>})
end;
db_req(#httpd{path_parts=[_,<<"_bulk_docs">>]}=Req, _Db) ->
diff --git a/test/javascript/tests/bulk_docs.js b/test/javascript/tests/bulk_docs.js
index b9e9716..9f88e81 100644
--- a/test/javascript/tests/bulk_docs.js
+++ b/test/javascript/tests/bulk_docs.js
@@ -110,6 +110,16 @@ couchTests.bulk_docs = function(debug) {
T(result.error == "bad_request");
T(result.reason == "POST body must include `docs` parameter.");
+ // verify that sending a request with invalid `new_edits` causes error
+ var req = CouchDB.request("POST", "/" + db_name + "/_bulk_docs", {
+ body: JSON.stringify({"docs": [], "new_edits": 0})
+ });
+
+ T(req.status == 400);
+ result = JSON.parse(req.responseText);
+ T(result.error == "bad_request");
+ T(result.reason == "`new_edits` parameter must be a boolean.");
+
// jira-911
db.deleteDb();
// avoid Heisenbugs w/ files remaining - create a new name
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.