From user-return-18182-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Oct 4 03:57:19 2011 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 539A47DD6 for ; Tue, 4 Oct 2011 03:57:19 +0000 (UTC) Received: (qmail 13917 invoked by uid 500); 4 Oct 2011 03:57:17 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 13875 invoked by uid 500); 4 Oct 2011 03:57:17 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 13867 invoked by uid 99); 4 Oct 2011 03:57:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 03:57:16 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of marcello.nuccio@gmail.com designates 209.85.160.180 as permitted sender) Received: from [209.85.160.180] (HELO mail-gy0-f180.google.com) (209.85.160.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 03:57:11 +0000 Received: by gyd8 with SMTP id 8so119570gyd.11 for ; Mon, 03 Oct 2011 20:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=6x5WK8uTtEpgDEnJwX1apdCajd8i1ILrie6GU7tQYeM=; b=FzCnYt6Cl/pokjJ6PwN4owzCht31K4XdGhW583oWUQz76NhAMD+AXMUjD02mlhUcZu 1el+hp/TrxbZvyqRJD4IvRpbnmJ6Y9bmgzblaUip0LTSvUvugEdFs1KaYcFaMpUyWgdI fc4GvA/frGDOhHw03XfR4pdK8ll8syC/p+JeQ= MIME-Version: 1.0 Received: by 10.68.38.42 with SMTP id d10mr6326728pbk.50.1317700610184; Mon, 03 Oct 2011 20:56:50 -0700 (PDT) Received: by 10.143.90.15 with HTTP; Mon, 3 Oct 2011 20:56:50 -0700 (PDT) In-Reply-To: References: Date: Tue, 4 Oct 2011 05:56:50 +0200 Message-ID: Subject: Re: update handler: how to return a status code? From: Marcello Nuccio To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable >From the [wiki][1]: Though you can set the headers, right now the status code for an update function response is hardcoded to be 200/201 unless an error occurs. See [this issue][2] in JIRA. And the issue was fixed a few days ago. [1]: http://wiki.apache.org/couchdb/Document_Update_Handlers [2]: https://issues.apache.org/jira/browse/COUCHDB-648 Marcello 2011/10/3 Gregor Martynus : > This is my update handler > > function (doc, req) { > =C2=A0var resp; > =C2=A0if (doc =3D=3D null) { > =C2=A0 =C2=A0doc =3D {}; > =C2=A0} > =C2=A0if (doc.email) { > =C2=A0 =C2=A0resp =3D { > =C2=A0 =C2=A0 =C2=A0status: 403, > =C2=A0 =C2=A0 =C2=A0body: 'already signed up with ' + doc.email > =C2=A0 =C2=A0}; > =C2=A0 =C2=A0return [doc, resp]; > =C2=A0} else { > =C2=A0 =C2=A0... > =C2=A0} > } > > Instead of a response with an 403 error, I get a 500 with this content: > {"error":"external_response_error","reason":"Invalid data from external > server: {<<\"status\">>,403}"} > > The logs don't tell more neither. > > Is this a bug or is it simply not intended to work this way? > > =E2=80=93 Gregor > > > > PS: Just figured out that it works like that: > throw(['error', 'forbidden','already signed up with ' + doc.email) > > I'd still appreciate an explanation >