You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Chris Anderson (JIRA)" <ji...@apache.org> on 2009/01/30 04:52:59 UTC
[jira] Closed: (COUCHDB-226) HTTP response codes on doc conflict
and database conflict may not agree with HTTP spec
[ https://issues.apache.org/jira/browse/COUCHDB-226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chris Anderson closed COUCHDB-226.
----------------------------------
Resolution: Fixed
I'm committing a fix for this. It was a very easy patch to make. I figure that because it's marked "Blocker" I can assume that we're in agreement that the error codes should be swapped.
I agree strongly with Paul's assertions that 409 is the correct error code for document update conflicts, and I agree weakly that 412 is a better error code for PUTs to existing database urls.
Fixed in r739157
> 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.
Re: [jira] Closed: (COUCHDB-226) HTTP response codes on doc conflict and database conflict may not agree with HTTP spec
Posted by Jan Lehnardt <ja...@apache.org>.
On 30 Jan 2009, at 04:52, Chris Anderson (JIRA) wrote:
>
> [ https://issues.apache.org/jira/browse/COUCHDB-226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
> ]
>
> Chris Anderson closed COUCHDB-226.
> ----------------------------------
>
> Resolution: Fixed
>
> I'm committing a fix for this. It was a very easy patch to make. I
> figure that because it's marked "Blocker" I can assume that we're in
> agreement that the error codes should be swapped.
For the record. I meant to blocking to mean "API is involved, might
need discussion". But in this case, the consensus is there, I think.
Cheers
Jan
--