incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: Understanding couchdb error messages
Date Tue, 25 Aug 2009 19:09:16 GMT
On Tue, Aug 25, 2009 at 3:02 PM, Hadley Wickham<hadley@rice.edu> wrote:
> Hi all,
>
> Do you have any tips to offer on interpreting couch db error messages?
>  For example, take the error below:
>
> =ERROR REPORT==== 25-Aug-2009::13:58:08 ===
> ** Generic server <0.20641.8> terminating
> ** Last message in was {'EXIT',<0.20640.8>,
>                           {{badmatch,
>                                <<"Cannot encode 'undefined' value
as JSON">>},
>                            [{couch_query_servers,reduce,3},
>                             {couch_view_group,'-init_group/4-fun-0-',4},
>                             {couch_btree,'-write_node/3-lc$^0/1-0-',3},
>                             {couch_btree,write_node,3},
>                             {couch_btree,modify_node,4},
>                             {couch_btree,query_modify,4},
>                             {couch_btree,add_remove,3},
>                             {couch_view_updater,
>                                 '-write_changes/4-lc$^3/1-3-',2}]}}
> ** When Server state == {file_descriptor,prim_file,{#Port<0.1471>,18}}
> ** Reason for termination ==
> ** {{badmatch,<<"Cannot encode 'undefined' value as JSON">>},
>    [{couch_query_servers,reduce,3},
>     {couch_view_group,'-init_group/4-fun-0-',4},
>     {couch_btree,'-write_node/3-lc$^0/1-0-',3},
>     {couch_btree,write_node,3},
>     {couch_btree,modify_node,4},
>     {couch_btree,query_modify,4},
>     {couch_btree,add_remove,3},
>     {couch_view_updater,'-write_changes/4-lc$^3/1-3-',2}]}
> 1> [error] [<0.20641.8>] {error_report,<0.25.0>,
>    {<0.20641.8>,crash_report,
>     [[{initial_call,{couch_file,init,['Argument__1']}},
>       {pid,<0.20641.8>},
>       {registered_name,[]},
>       {error_info,
>           {exit,
>               {{badmatch,<<"Cannot encode 'undefined' value as JSON">>},
>                [{couch_query_servers,reduce,3},
>                 {couch_view_group,'-init_group/4-fun-0-',4},
>                 {couch_btree,'-write_node/3-lc$^0/1-0-',3},
>                 {couch_btree,write_node,3},
>                 {couch_btree,modify_node,4},
>                 {couch_btree,query_modify,4},
>                 {couch_btree,add_remove,3},
>                 {couch_view_updater,'-write_changes/4-lc$^3/1-3-',2}]},
>               [{gen_server,terminate,6},{proc_lib,init_p_do_apply,3}]}},
>       {ancestors,
>           [<0.20640.8>,couch_view,couch_secondary_services,couch_server_sup,
>            <0.1.0>]},
>       {messages,[]},
>       {links,[#Port<0.1471>]},
>       {dictionary,[]},
>       {trap_exit,true},
>       {status,running},
>       {heap_size,1597},
>       {stack_size,24},
>       {reductions,462029}],
>      []]}}
>
> I can see that the basic problem appears to be "Cannot encode
> 'undefined' value as JSON", but how can I tell which view is having
> this problem, and which particular record is causing the problem?
>
> This should be really easy for me to figure out given that I only have
> two views. I'm using one to create a index so I can look articles up
> by keywords:
>
> map: function(doc) {
>  for(i in doc.keywords) {
>    emit(doc.keywords[i], null)
>  }
> }
>
> and the other just to count the number of articles that use a keyword:
>
> map: function(doc) {
>  for(i in doc.keywords) {
>    emit(doc.keywords[i], 1)
>  }
> }
>
> reduce: function(keys, values, rereduce) {
>  sum(values)
> }
>
> What am I doing wrong?
>
> Thanks!
>
> Hadley
> --
> http://had.co.nz/
>

The important bit:

<<"Cannot encode 'undefined' value as JSON">>

Means we're missing something in the view server, but the underlying
cause is that you're accessing a JavaScript member that doesn't exist.
Something like:

var f = {"stuff": "here"};
emit(f.not_an_member, null);

Both of your maps look all right though. Is that all there is, or is
there something else that wasn't pasted?

HTH,
Paul Davis

Mime
View raw message