andrewnet opened a new issue #1408: Response of bulk delete by endpoint 
"_bulk_docs" cannot distinguish reason of the typical failures
URL: https://github.com/apache/couchdb/issues/1408
 
 
   ## Expected Behavior
   Use should be able to tell the reason of failures base on the response of 
deleting documents through bulk endpoint "_bulk_docs". Otherwise, the bulk 
endpoint is not useful and user has to fall back to retrieve the document to 
find out what happened. The typical failures should at least include:
   * document does not exist
   * document has been deleted
   * document has been modified (i.e. _rev doesn't match)
   
   ## Current Behavior
   The response of deleting document through bulk endpoint "_bulk_docs" returns 
the same response `[{"id":"doc1","error":"conflict","reason":"Document update 
conflict."}]` for all these failures:
   * document does not exist
   * document has been deleted
   * document has been modified (i.e. _rev doesn't match)
   
   ## Possible Solution
   The `error` and `reason` attributes should contain enough information for 
the user to distinguish the reason of the failures.
   
   ## Steps to Reproduce (for bugs)
   As shown in the steps, the case 1, 2, and 3 all return the same error, there 
is no way to know why the delete failed.
   ```
   $ curl localhost:5984/example_db/doc1 -XPUT -d {}  # create new document
   {"ok":true,"id":"doc1","rev":"1-967a00dff5e02add41819138abb3284d"}
   
   #---------------------
   # case 1
   #---------------------
   $ curl localhost:5984/example_db/_bulk_docs -XPOST 
-Hcontent-type:application/json -d 
'{"docs":[{"_id":"doc1","_rev":"3-967a00dff5e02add41819138abb3284d","_deleted":true}]}'
  # attempt to delete the document but the given _rev does not match
   [{"id":"doc1","error":"conflict","reason":"Document update conflict."}]
   
   $ curl localhost:5984/example_db/_bulk_docs -XPOST 
-Hcontent-type:application/json -d 
'{"docs":[{"_id":"doc1","_rev":"1-967a00dff5e02add41819138abb3284d","_deleted":true}]}'
  # delete document by giving correct _rev
   [{"ok":true,"id":"doc1","rev":"2-eec205a9d413992850a6e32678485900"}]
   
   #---------------------
   # case 2
   #---------------------
   $ curl localhost:5984/example_db/_bulk_docs -XPOST 
-Hcontent-type:application/json -d 
'{"docs":[{"_id":"doc1","_rev":"1-967a00dff5e02add41819138abb3284d","_deleted":true}]}'
  # attempt to delete the document again, this represent the case the document 
existed before but was deleted now
   [{"id":"doc1","error":"conflict","reason":"Document update conflict."}]
   
   #---------------------
   # case 3
   #---------------------
   $ curl localhost:5984/example_db/_bulk_docs -XPOST 
-Hcontent-type:application/json -d 
'{"docs":[{"_id":"dummy_id","_rev":"1-967a00dff5e02add41819138abb3284d","_deleted":true}]}'
  # attempt to delete a document never existed before
   [{"id":"dummy_id","error":"conflict","reason":"Document update conflict."}]
   ```
   
   ## Context
   We need to loop through all the documents in the database and update or 
delete certain documents, when the delete failed, we have no way to know why it 
failed. If we know the reason of the failure, we should be able to act 
accordingly. As the result, we can't use the bulk endpoint for deletion, or we 
have to try to retrieve the document to determine what could be the reason of 
the failure.
   
   ## Your Environment
   * Version used: Cloudant on cloud, same problem exist in all versions
   * Browser Name and version: not related
   * Operating System and version (desktop or mobile): not related
   * Link to your project: private
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to