Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 1438 invoked from network); 2 Nov 2009 20:41:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Nov 2009 20:41:25 -0000 Received: (qmail 68210 invoked by uid 500); 2 Nov 2009 20:41:24 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 67744 invoked by uid 500); 2 Nov 2009 20:41:23 -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 67678 invoked by uid 99); 2 Nov 2009 20:41:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2009 20:41:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2009 20:41:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 4E971234C4E7 for ; Mon, 2 Nov 2009 12:41:00 -0800 (PST) Message-ID: <44585630.1257194460320.JavaMail.jira@brutus> Date: Mon, 2 Nov 2009 20:41:00 +0000 (UTC) From: "Adam Kocoloski (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Updated: (COUCHDB-410) JavaScript errors in validate_doc_update should be handled more gracefully In-Reply-To: <1639062757.1247328374797.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-410?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Adam Kocoloski updated COUCHDB-410: ----------------------------------- Fix Version/s: (was: 0.9.2) 0.11 I don't think there's going to be an 0.9.2, adjusting FixFor to 0.11 > JavaScript errors in validate_doc_update should be handled more gracefull= y > -------------------------------------------------------------------------= - > > Key: COUCHDB-410 > URL: https://issues.apache.org/jira/browse/COUCHDB-410 > Project: CouchDB > Issue Type: Bug > Components: Database Core > Affects Versions: 0.9.1, 0.10 > Reporter: Jason Davies > Fix For: 0.11 > > Attachments: util.js.diff > > > For example, if I create validate_doc_update: > function (oldDoc, newDoc, userCtx) { > doc.foo; > } > I am greeted by an "OS process timed out" message. In the logs, all I se= e is: > OS Process :: Error converting object to JSON: TypeError: {Array:function= (v) {var buf =3D [];for (var i =3D 0; i < v.length; i++) {buf.push(toJSON(= v[i]));}return "[" + buf.join(",") + "]";}, Boolean:function (v) {return v.= toString();}, Date:function (v) {var f =3D function (n) {return n < 10 ? "0= " + n : n;};return "\"" + v.getUTCFullYear() + "-" + f(v.getUTCMonth() + 1)= + "-" + f(v.getUTCDate()) + "T" + f(v.getUTCHours()) + ":" + f(v.getUTCMin= utes()) + ":" + f(v.getUTCSeconds()) + "Z\"";}, Number:function (v) {return= isFinite(v) ? v.toString() : "null";}, Object:function (v) {if (v =3D=3D= =3D null) {return "null";}var buf =3D [];for (var k in v) {if (!v.hasOwnPro= perty(k) || typeof k !=3D=3D "string" || v[k] =3D=3D=3D undefined) {continu= e;}buf.push(toJSON(k, val) + ": " + toJSON(v[k]));}return "{" + buf.join(",= ") + "}";}, String:function (v) {if (/["\\\x00-\x1f]/.test(v)) {v =3D v.rep= lace(/([\x00-\x1f\\"])/g, function (a, b) {var c =3D subs[b];if (c) {return= c;}c =3D b.charCodeAt();return "\\u00" + Math.floor(c / 16).toString(16) += (c % 16).toString(16);});}return "\"" + v + "\"";}}[val !=3D null ? val.co= nstructor.name : "Object"] is not a function > When really the problem is a ReferenceError (I should have used newDoc.fo= o or oldDoc.foo). The attached patch modifies toJSON() in utils.js so that= it converts anything that isn't a String, Array, Date, Object etc. into a = String. This makes the error appear in the popup in Futon when saving. > This isn't necessarily the best thing to do as it modifies the semantics = of toJSON(), and also we might want to keep the exception info in the logs,= and not propagate it to the user. Perhaps it would be better to modify re= spond(obj) to produce a better error message in the logs (simply adding som= ething that tried to log obj.toString() would suffice). --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.