From dev-return-12366-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Sat Oct 09 19:47:21 2010 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 92204 invoked from network); 9 Oct 2010 19:47:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Oct 2010 19:47:20 -0000 Received: (qmail 91576 invoked by uid 500); 9 Oct 2010 19:46:58 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 91519 invoked by uid 500); 9 Oct 2010 19:46:58 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 91487 invoked by uid 99); 9 Oct 2010 19:46:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Oct 2010 19:46:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Oct 2010 19:46:57 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o99JkbXR017520 for ; Sat, 9 Oct 2010 19:46:37 GMT Message-ID: <20786086.59571286653597149.JavaMail.jira@thor> Date: Sat, 9 Oct 2010 15:46:37 -0400 (EDT) From: "Paul Joseph Davis (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Updated: (COUCHDB-336) Would like errors in map function to be reported to client In-Reply-To: <1993126194.1240909710445.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul Joseph Davis updated COUCHDB-336: -------------------------------------- Skill Level: Regular Contributors Level (Easy to Medium) > Would like errors in map function to be reported to client > ---------------------------------------------------------- > > Key: COUCHDB-336 > URL: https://issues.apache.org/jira/browse/COUCHDB-336 > Project: CouchDB > Issue Type: Wish > Environment: svn trunk 0.10.0a768591 > Reporter: Brian Candler > Priority: Minor > > At the moment, if a runtime error occurs in a map function, the document is silently excluded from the view and the client is none the wiser. > $ curl -X PUT http://127.0.0.1:5984/test > {"ok":true} > $ curl -d '{"foo":"bar"}' -X PUT http://127.0.0.1:5984/test/doc1 > {"ok":true,"id":"doc1","rev":"1-3413565576"} > $ curl -d '{"food":"bar"}' -X PUT http://127.0.0.1:5984/test/doc2 > {"ok":true,"id":"doc2","rev":"1-2088327893"} > # Example 1: map function calls undefined function > $ curl -d '{"map":"function(doc) { emitt(null,null); }"}' -H 'Content-Type: application/json' -X POST http://127.0.0.1:5984/test/_temp_view > {"total_rows":0,"rows":[]} > # Example 2: map function attempts to emit 'undefined' > $ curl -d '{"map":"function(doc) { emit(doc._id,doc.foo); }"}' -H 'Content-Type: application/json' -X POST http://127.0.0.1:5984/test/_temp_view > {"total_rows":1,"offset":0,"rows":[ > {"id":"doc1","key":"doc1","value":"bar"} > ]} > Of course, errors are available in the server log: > [Tue, 28 Apr 2009 08:40:39 GMT] [info] [<0.1276.0>] OS Process Log Message: function raised exception (ReferenceError: emitt is not defined) with doc._id doc1 > [Tue, 28 Apr 2009 08:43:44 GMT] [info] [<0.1276.0>] OS Process Log Message: function raised exception (Cannot encode 'undefined' value as JSON) with doc._id doc2 > But the client cannot see these, and worse, gets what appears to be a valid result set. > I think there are two cases to consider. > - in temporary views, it ought to be easy to do something: e.g. (1) return the full set of failed docs with their errors, or (2) return a count of failed docs, or (3) just abort on the first error > - in permanent views, it might also be useful to return this information, but it could be expensive to persist. Also, when you're querying for key X you might not want to see a whole load of errors for unrelated docs. An error count might be OK though, similar to total_rows. > The current behaviour may be useful, although I personally wouldn't want to rely on it, especially as it generates errors in the log. That is, I would rather be forced to rewrite example 2 as > function(doc) { if (doc.foo) { emit(doc._id, doc.foo); } } > or > function(doc) { emit(doc._id, doc.foo || null); } > as appropriate. > Workaround: users can manually wrap each of their map functions in a catcher which emits a sentinel key/value pair containing the error. However they would still have to query the key range which includes the error messages. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.