You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Cliff Stanford <cl...@may.be> on 2010/02/02 12:40:01 UTC

validate_doc_update result format

According to http://wiki.apache.org/couchdb/Security_Features_Overview 
the the following validation function:

validate_doc_update: "function(newDoc, oldDoc, userCtx) {
     throw {missing_field: 'Document must have an address.'};
}"

should give the result:

HTTP/1.1 401 Unauthorized
...
{"error":"missing_field","reason":"Document must have an address."}

Using the released CouchDB 0.10.0 I get the following result:

HTTP/1.1 500 Internal Server Error
...
{"error":"try_clause","reason":"{[{<<\"missing_field\">>,<<\"Document 
must have an address.\">>}]}"}

This looks like a bug to me.  Is there a better place to post this kind 
of report?

Regards,
Cliff.

-- 
Cliff Stanford
Might Limited                           +44 845 0045 666 (Office)
Suite 67, Dorset House                  +44 7973 616 666 (Mobile)
Duke Street, Chelmsford, CM1 1TB


Re: validate_doc_update result format

Posted by Chris Anderson <jc...@apache.org>.
On Tue, Feb 2, 2010 at 7:23 AM, Zachary Zolton <za...@gmail.com> wrote:
> Cliff,
>
> Perhaps the wiki is out of date? The follow seemed to work for me:

Thanks for the notice -- I've fixed the wiki

>
>  throw({unauthorized : message});  // for invalid data
>
> OR
>
>  throw({forbidden : message});  // for unauthorized updates
>
> Whereas adding any other attribute to the throw object resulted in a 500 error.
>
> The CouchDB book looks up-to-date on the matter:
> http://books.couchdb.org/relax/design-documents/validation-functions
>
>
> Cheers,
>
> Zach
>
> On Tue, Feb 2, 2010 at 5:40 AM, Cliff Stanford <cl...@may.be> wrote:
>> According to http://wiki.apache.org/couchdb/Security_Features_Overview the
>> the following validation function:
>>
>> validate_doc_update: "function(newDoc, oldDoc, userCtx) {
>>    throw {missing_field: 'Document must have an address.'};
>> }"
>>
>> should give the result:
>>
>> HTTP/1.1 401 Unauthorized
>> ...
>> {"error":"missing_field","reason":"Document must have an address."}
>>
>> Using the released CouchDB 0.10.0 I get the following result:
>>
>> HTTP/1.1 500 Internal Server Error
>> ...
>> {"error":"try_clause","reason":"{[{<<\"missing_field\">>,<<\"Document must
>> have an address.\">>}]}"}
>>
>> This looks like a bug to me.  Is there a better place to post this kind of
>> report?
>>
>> Regards,
>> Cliff.
>>
>> --
>> Cliff Stanford
>> Might Limited                           +44 845 0045 666 (Office)
>> Suite 67, Dorset House                  +44 7973 616 666 (Mobile)
>> Duke Street, Chelmsford, CM1 1TB
>>
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: validate_doc_update result format

Posted by Zachary Zolton <za...@gmail.com>.
Cliff,

Perhaps the wiki is out of date? The follow seemed to work for me:

  throw({unauthorized : message});  // for invalid data

OR

  throw({forbidden : message});  // for unauthorized updates

Whereas adding any other attribute to the throw object resulted in a 500 error.

The CouchDB book looks up-to-date on the matter:
http://books.couchdb.org/relax/design-documents/validation-functions


Cheers,

Zach

On Tue, Feb 2, 2010 at 5:40 AM, Cliff Stanford <cl...@may.be> wrote:
> According to http://wiki.apache.org/couchdb/Security_Features_Overview the
> the following validation function:
>
> validate_doc_update: "function(newDoc, oldDoc, userCtx) {
>    throw {missing_field: 'Document must have an address.'};
> }"
>
> should give the result:
>
> HTTP/1.1 401 Unauthorized
> ...
> {"error":"missing_field","reason":"Document must have an address."}
>
> Using the released CouchDB 0.10.0 I get the following result:
>
> HTTP/1.1 500 Internal Server Error
> ...
> {"error":"try_clause","reason":"{[{<<\"missing_field\">>,<<\"Document must
> have an address.\">>}]}"}
>
> This looks like a bug to me.  Is there a better place to post this kind of
> report?
>
> Regards,
> Cliff.
>
> --
> Cliff Stanford
> Might Limited                           +44 845 0045 666 (Office)
> Suite 67, Dorset House                  +44 7973 616 666 (Mobile)
> Duke Street, Chelmsford, CM1 1TB
>
>