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 2018/11/28 16:02:04 UTC

[GitHub] eiri commented on a change in pull request #1770: Fix couchdb 1384 function clause error

eiri commented on a change in pull request #1770: Fix couchdb 1384 function clause error
URL: https://github.com/apache/couchdb/pull/1770#discussion_r237146904
 
 

 ##########
 File path: src/couch/src/couch_db.erl
 ##########
 @@ -730,12 +730,22 @@ validate_security_object(SecProps) ->
     % we fallback to readers here for backwards compatibility
     Members = couch_util:get_value(<<"members">>, SecProps,
         couch_util:get_value(<<"readers">>, SecProps, {[]})),
-    ok = validate_names_and_roles(Admins),
-    ok = validate_names_and_roles(Members),
+    case Admins of
 
 Review comment:
   This is inefficient way to go about this, you are essentially splitting validation logic in two places instead of fixing it in the dedicated validator.
   
   Better (and shorter) approach would be to add a "catch all" validator function to raise errors, like this:
   ```diff
   @@ -759,6 +749,8 @@ validate_names_and_roles(Props) when is_list(Props) ->
        _ -> throw("roles must be a JSON list of strings")
        end,
        ok.
   +validate_names_and_roles(_) ->
   +    throw("members must be a JSON list of strings").
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services