You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Brian Candler <B....@pobox.com> on 2009/03/19 16:30:46 UTC

_bulk_docs parsing and error handling

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"