You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/04/11 03:08:16 UTC

[GitHub] [couchdb] jiahuili430 opened a new pull request, #3990: Fix index creation with empty ddoc

jiahuili430 opened a new pull request, #3990:
URL: https://github.com/apache/couchdb/pull/3990

   <!-- Thank you for your contribution!
   
        Please file this form by replacing the Markdown comments
        with your text. If a section needs no action - remove it.
   
        Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
        of code collaboration. Positive feedback is represented +1 from committers
        and negative is a -1. The -1 also means veto, and needs to be addressed
        to proceed. Once there are no objections, the PR can be merged by a
        CouchDB committer.
   
        See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
   
   ## Overview
   
   <!-- Please give a short brief for the pull request,
        what problem it solves or how it makes things better. -->
   
   ## Testing recommendations
   
   <!-- Describe how we can test your changes.
        Does it provides any behaviour that the end users
        could notice? -->
   
   ## Related Issues or Pull Requests
   https://github.com/apache/couchdb/issues/1472
   <!-- If your changes affects multiple components in different
        repositories please put links to those issues or pull requests here.  -->
   
   ## Checklist
   
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [ ] A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] tonysun83 merged pull request #3990: Creating index with empty "name"/"ddoc" should return 400

Posted by GitBox <gi...@apache.org>.
tonysun83 merged PR #3990:
URL: https://github.com/apache/couchdb/pull/3990


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] jiahuili430 commented on a diff in pull request #3990: Creating index with "ddoc":"" should return 400 Bad Request

Posted by GitBox <gi...@apache.org>.
jiahuili430 commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r850785278


##########
src/mango/src/mango_opts.erl:
##########
@@ -240,6 +241,13 @@ validate_idx_name(auto_name) ->
 validate_idx_name(Else) ->
     is_string(Else).
 
+validate_idx_ddoc(auto_name) ->

Review Comment:
   Changed, thanks for the review.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] iilyak commented on a diff in pull request #3990: Creating index with "ddoc":"" should return 400 Bad Request

Posted by GitBox <gi...@apache.org>.
iilyak commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r850535212


##########
src/mango/src/mango_opts.erl:
##########
@@ -240,6 +241,13 @@ validate_idx_name(auto_name) ->
 validate_idx_name(Else) ->
     is_string(Else).
 
+validate_idx_ddoc(auto_name) ->

Review Comment:
   It seems like there is another similar bug in the area. Someone could give `name = ""`, which doesn't make sense.
   
   Therefore I propose different fix.
   
   ```
   non_empty_string(<<>> = Else)  ->
       ?MANGO_ERROR({invalid_non_empty_string, Else}).
   non_empty_string(Val) when is_binary(Val) ->
       {ok, Val};
   non_empty_string(Else) ->
       ?MANGO_ERROR({invalid_non_empty_string, Else}).
       
   validate_idx_name(auto_name) ->
       {ok, auto_name};
   validate_idx_name(Else) ->
       non_emtpy_string(Else).
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] jiahuili430 commented on a diff in pull request #3990: Creating index with empty "name"/"ddoc" should return 400

Posted by GitBox <gi...@apache.org>.
jiahuili430 commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r856502513


##########
src/mango/test/01-index-crud-test.py:
##########
@@ -68,17 +68,17 @@ def test_bad_types(self):
             else:
                 raise AssertionError("bad create index")
 
-    def test_bad_names(self):
-        bad_names = [True, False, 1.5, {"foo": "bar"}, [None, False]]
-        for bn in bad_names:
+    def test_bad_names_ddocs(self):
+        bad_args = ["", True, False, 1.5, {"foo": "bar"}, [None, False]]

Review Comment:
   Added another test case [test_bad_ddocs()](https://github.com/apache/couchdb/pull/3990/files#diff-243cff897c08c3a4b060fed2dc84a22d35740500fbf075e6209ba5013f0fd7faR81), thanks for the review.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] tonysun83 commented on a diff in pull request #3990: Creating index with empty "name"/"ddoc" should return 400

Posted by GitBox <gi...@apache.org>.
tonysun83 commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r856475359


##########
src/mango/test/01-index-crud-test.py:
##########
@@ -68,17 +68,17 @@ def test_bad_types(self):
             else:
                 raise AssertionError("bad create index")
 
-    def test_bad_names(self):
-        bad_names = [True, False, 1.5, {"foo": "bar"}, [None, False]]
-        for bn in bad_names:
+    def test_bad_names_ddocs(self):
+        bad_args = ["", True, False, 1.5, {"foo": "bar"}, [None, False]]

Review Comment:
   this only tests for `"name": ""` ? Can we add a testcase where `"ddoc": ""` can it receives the same error? The original bug has `"ddoc" : ""`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] tonysun83 commented on a diff in pull request #3990: Creating index with empty "name"/"ddoc" should return 400

Posted by GitBox <gi...@apache.org>.
tonysun83 commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r856475359


##########
src/mango/test/01-index-crud-test.py:
##########
@@ -68,17 +68,17 @@ def test_bad_types(self):
             else:
                 raise AssertionError("bad create index")
 
-    def test_bad_names(self):
-        bad_names = [True, False, 1.5, {"foo": "bar"}, [None, False]]
-        for bn in bad_names:
+    def test_bad_names_ddocs(self):
+        bad_args = ["", True, False, 1.5, {"foo": "bar"}, [None, False]]

Review Comment:
   this only tests for `"name": ""` ? Can we add a testcase where `"ddoc": ""` and it receives the same error? The original bug has `"ddoc" : ""`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] tonysun83 commented on a diff in pull request #3990: Creating index with empty "name"/"ddoc" should return 400

Posted by GitBox <gi...@apache.org>.
tonysun83 commented on code in PR #3990:
URL: https://github.com/apache/couchdb/pull/3990#discussion_r856476077


##########
src/mango/src/mango_error.erl:
##########
@@ -266,11 +266,11 @@ info(mango_opts, {invalid_selector_json, BadSel}) ->
         <<"invalid_selector_json">>,
         fmt("Selector must be a JSON object, not: ~w", [BadSel])
     };
-info(mango_opts, {invalid_index_name, BadName}) ->
+info(mango_opts, invalid_empty_string) ->
     {
         400,
-        <<"invalid_index_name">>,
-        fmt("Invalid index name: ~w", [BadName])
+        <<"invalid_empty_string">>,
+        <<"Index name/ddoc cannot be empty">>

Review Comment:
   <<"Index name or ddoc cannot be empty string">>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org