couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject _bulk_docs parsing and error handling
Date Thu, 19 Mar 2009 15:30:46 GMT
I see that the response from _bulk_docs has been changed so that it's a
simple JSON array, rather than an object:

[
    {"id":"doc1","rev":"1-1708578174"},
    {"id":"doc2","error":"conflict","reason":"Document update conflict."}
]

So I was checking to see whether the request format had changed to be
consistent with this. I found that a normal _bulk_docs request works
properly:

    {"docs":[{...}, {...}, {...}]}

But when I send a request of the form

    [{...},{...},{...}]

CouchDB drops the connection on the floor - not even a status 500 line!

So I think the error handling could be made a bit saner. Whether it's worth
changing the _bulk_docs API to allow a simple array is a separate issue.

Regards,

Brian.

---- code to replicate ----
#!/bin/sh
set -x

HOST1=http://localhost:5984
LOCAL1=sampledb
DB1="$HOST1/$LOCAL1"

curl -X DELETE "$DB1"
curl -X PUT "$DB1"

# works
curl -svX POST -d "{\"docs\":[
{\"_id\":\"doc1\",\"hello\":\"world\"},
]}" "${DB1}/_bulk_docs"

# fails with connection dropped on the floor
curl -svX POST -d "[
{\"_id\":\"doc1\",\"hello\":\"world\"},
]" "${DB1}/_bulk_docs"


Mime
View raw message