Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 9649 invoked from network); 30 Jan 2009 14:50:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Jan 2009 14:50:23 -0000 Received: (qmail 62095 invoked by uid 500); 30 Jan 2009 14:50:23 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 61776 invoked by uid 500); 30 Jan 2009 14:50:22 -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 61765 invoked by uid 99); 30 Jan 2009 14:50:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jan 2009 06:50:21 -0800 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; Fri, 30 Jan 2009 14:50:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C05EB234C4B3 for ; Fri, 30 Jan 2009 06:49:59 -0800 (PST) Message-ID: <201287138.1233326999786.JavaMail.jira@brutus> Date: Fri, 30 Jan 2009 06:49:59 -0800 (PST) From: "Paul Carey (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Commented: (COUCHDB-226) HTTP response codes on doc conflict and database conflict may not agree with HTTP spec In-Reply-To: <1686539829.1232803199508.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668887#action_12668887 ] Paul Carey commented on COUCHDB-226: ------------------------------------ So, there's consensus on returning a 409 in case of document update conflict, good. I'm a little ambivalent about returning a 412 in case of a PUT to an existing database, although I don't think it should be a 409, because, as the spec states "This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request". If we're hunting for more suitable error codes, perhaps a 403 might be better - the server understood the request, but isn't going to fulfil it and nor should the request be repeated. I don't feel strongly about this though. My main issue was the response code on document conflict, this has been resolved, I'm happy. > HTTP response codes on doc conflict and database conflict may not agree with HTTP spec > --------------------------------------------------------------------------------------- > > Key: COUCHDB-226 > URL: https://issues.apache.org/jira/browse/COUCHDB-226 > Project: CouchDB > Issue Type: Bug > Components: HTTP Interface > Affects Versions: 0.9 > Reporter: Paul Carey > Assignee: Jan Lehnardt > Priority: Blocker > Fix For: 0.9 > > > I'm creating this issue as per Jan's request. It was originally posted to the mailing list a short while ago. > ==== > An attempt to create an already existing database returns a 409. > $ curl -v -s -X PUT localhost:5984/shiny_new_db 2>&1 | grep '< HTTP' > < HTTP/1.1 201 Created > $ curl -v -s -X PUT localhost:5984/shiny_new_db 2>&1 | grep '< HTTP' > < HTTP/1.1 409 Conflict > From the 409 section of the HTTP spec [1] > "This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request." > But the database already exists - there is no resolution, so I'm not sure a 409 is the best response code here. > The 412 section of the spec states > "The precondition given in one or more of the request-header fields evaluated to false" > Arguably, this is what should be returned when an attempt is made to re-create a pre-existing database - the precondition is that you can PUT to a database URI at most once. > As for document conflict, CouchDB returns a 412. > $ curl -v -s -X PUT -d '{"_id":"foo"}' localhost:5984/shiny_new_db/foo > 2>&1 | grep '< HTTP' > < HTTP/1.1 201 Created > $ curl -v -s -X PUT -d '{"_id":"foo"}' localhost:5984/shiny_new_db/foo > 2>&1 | grep '< HTTP' > < HTTP/1.1 412 Precondition Failed > I think a document conflict might have returned a 409 at some point in the past. In fact this is what the Document API wiki page [2] states it returns. Given that the user may resolve the conflict and resubmit the request, a 409 makes sense here. > To clarify, unless I'm missing something, I think an attempt to create an already existing database should return a 412 and an attempt to update a document that results in a conflict should return a 409. > [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html > [2] http://wiki.apache.org/couchdb/HTTP_Document_API -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.