You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Travis Paul <tr...@gmail.com> on 2013/01/03 01:21:24 UTC

Strange JavaScript behavior in validate_doc_update functions

In one of my validate_doc_update functions I try to throw an array of
errors like so:

    if (report.errors.length) {
       throw({forbidden: report.errors});
    }

and couchdb crashes (but recovers of course)

If I stringify the errors array, it works fine...

    if (report.errors.length) {
       throw({forbidden: JSON.stringify(report.errors)});
    }

report.errors looks like: http://pastebin.com/JzqtvUSd
and the crash report: http://pastebin.com/Wp679hux

I'm running couchdb 1.0.3 and I was using Futon to save the document and
erica to push the couchapp. I am using JSV to get the errors array.

I would be happy to put my couchapp somewhere (github) if it will help find
the cause. I am just trying to use json-schema in a demo couchapp.

Any insight would be appreciated.

Re: Strange JavaScript behavior in validate_doc_update functions

Posted by Travis Paul <Tr...@visPaul.me>.
Thanks Robert, I filed a JIRA ticket.


On Thu, Jan 3, 2013 at 5:35 AM, Robert Newson <rn...@apache.org> wrote:

> error_info({Error, Reason}) when is_list(Reason) ->
>     error_info({Error, ?l2b(Reason)});
>
> This clause assumes, erroneously, that a list is really a string and
> so converts it to a binary. In this case, the list contains objects.
>
> B.
>
> On 3 January 2013 10:24, Robert Newson <rn...@apache.org> wrote:
> > I can easily believe our error handling code assumes a string for the
> > error value. File a JIRA ticket?
> >
> > On 3 January 2013 00:21, Travis Paul <tr...@gmail.com> wrote:
> >> In one of my validate_doc_update functions I try to throw an array of
> >> errors like so:
> >>
> >>     if (report.errors.length) {
> >>        throw({forbidden: report.errors});
> >>     }
> >>
> >> and couchdb crashes (but recovers of course)
> >>
> >> If I stringify the errors array, it works fine...
> >>
> >>     if (report.errors.length) {
> >>        throw({forbidden: JSON.stringify(report.errors)});
> >>     }
> >>
> >> report.errors looks like: http://pastebin.com/JzqtvUSd
> >> and the crash report: http://pastebin.com/Wp679hux
> >>
> >> I'm running couchdb 1.0.3 and I was using Futon to save the document and
> >> erica to push the couchapp. I am using JSV to get the errors array.
> >>
> >> I would be happy to put my couchapp somewhere (github) if it will help
> find
> >> the cause. I am just trying to use json-schema in a demo couchapp.
> >>
> >> Any insight would be appreciated.
>

Re: Strange JavaScript behavior in validate_doc_update functions

Posted by Robert Newson <rn...@apache.org>.
error_info({Error, Reason}) when is_list(Reason) ->
    error_info({Error, ?l2b(Reason)});

This clause assumes, erroneously, that a list is really a string and
so converts it to a binary. In this case, the list contains objects.

B.

On 3 January 2013 10:24, Robert Newson <rn...@apache.org> wrote:
> I can easily believe our error handling code assumes a string for the
> error value. File a JIRA ticket?
>
> On 3 January 2013 00:21, Travis Paul <tr...@gmail.com> wrote:
>> In one of my validate_doc_update functions I try to throw an array of
>> errors like so:
>>
>>     if (report.errors.length) {
>>        throw({forbidden: report.errors});
>>     }
>>
>> and couchdb crashes (but recovers of course)
>>
>> If I stringify the errors array, it works fine...
>>
>>     if (report.errors.length) {
>>        throw({forbidden: JSON.stringify(report.errors)});
>>     }
>>
>> report.errors looks like: http://pastebin.com/JzqtvUSd
>> and the crash report: http://pastebin.com/Wp679hux
>>
>> I'm running couchdb 1.0.3 and I was using Futon to save the document and
>> erica to push the couchapp. I am using JSV to get the errors array.
>>
>> I would be happy to put my couchapp somewhere (github) if it will help find
>> the cause. I am just trying to use json-schema in a demo couchapp.
>>
>> Any insight would be appreciated.

Re: Strange JavaScript behavior in validate_doc_update functions

Posted by Robert Newson <rn...@apache.org>.
I can easily believe our error handling code assumes a string for the
error value. File a JIRA ticket?

On 3 January 2013 00:21, Travis Paul <tr...@gmail.com> wrote:
> In one of my validate_doc_update functions I try to throw an array of
> errors like so:
>
>     if (report.errors.length) {
>        throw({forbidden: report.errors});
>     }
>
> and couchdb crashes (but recovers of course)
>
> If I stringify the errors array, it works fine...
>
>     if (report.errors.length) {
>        throw({forbidden: JSON.stringify(report.errors)});
>     }
>
> report.errors looks like: http://pastebin.com/JzqtvUSd
> and the crash report: http://pastebin.com/Wp679hux
>
> I'm running couchdb 1.0.3 and I was using Futon to save the document and
> erica to push the couchapp. I am using JSV to get the errors array.
>
> I would be happy to put my couchapp somewhere (github) if it will help find
> the cause. I am just trying to use json-schema in a demo couchapp.
>
> Any insight would be appreciated.