You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Isaac Z. Schlueter (JIRA)" <ji...@apache.org> on 2012/07/08 19:42:34 UTC

[jira] [Created] (COUCHDB-1511) Error message provides no help: Uncaught server error: {case_clause,{[]}}

Isaac Z. Schlueter created COUCHDB-1511:
-------------------------------------------

             Summary: Error message provides no help: Uncaught server error: {case_clause,{[]}}
                 Key: COUCHDB-1511
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1511
             Project: CouchDB
          Issue Type: Bug
    Affects Versions: 1.2
            Reporter: Isaac Z. Schlueter


When PUTing a _users doc, if you forget the `roles:[]` field, you get this error, which doesn't help figure out the problem at all.

Suggestion:
1. _users docs should get a role:[] and type:"user" by default if these fields are missing.
2. If there is an error in the _users doc, it should say "Invalid user document", or something else indicating that the problem happened because the data was bad (and not, say, because the server is crashing or views are messed up, or whatever else can happen in this crazy world.)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (COUCHDB-1511) Error message provides no help: Uncaught server error: {case_clause,{[]}}

Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Newson resolved COUCHDB-1511.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3

The user will now receive a message stating that "doc.roles must exist" if it is not defined. This, in addition to the existing test that it must be an array, should fix the issue.
                
> Error message provides no help: Uncaught server error: {case_clause,{[]}}
> -------------------------------------------------------------------------
>
>                 Key: COUCHDB-1511
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1511
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.2
>            Reporter: Isaac Z. Schlueter
>             Fix For: 1.3
>
>
> When PUTing a _users doc, if you forget the `roles:[]` field, you get this error, which doesn't help figure out the problem at all.
> Suggestion:
> 1. _users docs should get a role:[] and type:"user" by default if these fields are missing.
> 2. If there is an error in the _users doc, it should say "Invalid user document", or something else indicating that the problem happened because the data was bad (and not, say, because the server is crashing or views are messed up, or whatever else can happen in this crazy world.)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1511) Error message provides no help: Uncaught server error: {case_clause,{[]}}

Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13409004#comment-13409004 ] 

Robert Newson commented on COUCHDB-1511:
----------------------------------------

The function should be examined for all errors of this clause, I doubt roles is the only bug.
                
> Error message provides no help: Uncaught server error: {case_clause,{[]}}
> -------------------------------------------------------------------------
>
>                 Key: COUCHDB-1511
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1511
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.2
>            Reporter: Isaac Z. Schlueter
>
> When PUTing a _users doc, if you forget the `roles:[]` field, you get this error, which doesn't help figure out the problem at all.
> Suggestion:
> 1. _users docs should get a role:[] and type:"user" by default if these fields are missing.
> 2. If there is an error in the _users doc, it should say "Invalid user document", or something else indicating that the problem happened because the data was bad (and not, say, because the server is crashing or views are messed up, or whatever else can happen in this crazy world.)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1511) Error message provides no help: Uncaught server error: {case_clause,{[]}}

Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13409003#comment-13409003 ] 

Robert Newson commented on COUCHDB-1511:
----------------------------------------

The reason for the error is that, while we test that newDoc.roles is an array if it's defined, we don't define it if it's absent and we then proceed to call newDoc.roles.length. The exception thrown here is not anticipated in the ddoc_prompt result, and we get a function_clause (which, as noted, is impenetrable to users).

The fix for couch_db_functions.hrl is something like this;

--- a/src/couchdb/couch_js_functions.hrl
+++ b/src/couchdb/couch_js_functions.hrl
@@ -31,8 +31,12 @@
             throw({forbidden: 'doc.name is required'});
         }
 
-        if (newDoc.roles && !isArray(newDoc.roles)) {
-            throw({forbidden: 'doc.roles must be an array'});
+        if (newDoc.roles) {
+            if (!isArray(newDoc.roles)) {
+              throw({forbidden: 'doc.roles must be an array'});
+            }
+        } else {
+            newDoc.roles = []
         }
 
and the fix for couch_query_servers will be to add something like;

_ ->
  throw({bad_request, "blah"})

                
> Error message provides no help: Uncaught server error: {case_clause,{[]}}
> -------------------------------------------------------------------------
>
>                 Key: COUCHDB-1511
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1511
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.2
>            Reporter: Isaac Z. Schlueter
>
> When PUTing a _users doc, if you forget the `roles:[]` field, you get this error, which doesn't help figure out the problem at all.
> Suggestion:
> 1. _users docs should get a role:[] and type:"user" by default if these fields are missing.
> 2. If there is an error in the _users doc, it should say "Invalid user document", or something else indicating that the problem happened because the data was bad (and not, say, because the server is crashing or views are messed up, or whatever else can happen in this crazy world.)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira