ArikShifer opened a new issue #584: Using Update Function throws occasional 412 
errors when documents has inline attachments
URL: https://github.com/apache/couchdb/issues/584
 
 
    I'm using javascript Update Functions to invoke server-side logic to update 
some individual fields in documents without first getting the latest revision 
as explained in: 
http://docs.couchdb.org/en/2.0.0/couchapp/ddocs.html?highlight=update%20handler.
   
    My documents have inline attachments. The individual fields I'm updating 
are not the document _attachments. On occasions I'm getting 412 'Precondition 
Failed' error with message 'Invalid attachment stub in <doc_id> for 
<attachment_name>'. 
   
   The error seems false positive because when I inspect the document I see 
that it has the updated content and the _attachments part looks intact (see 
example).
    
    "_attachments": {
       "content": {
         "content_type": "text/plain",
         "revpos": 1,
         "digest": "md5-H05fzZIvzFkyezESkSEwwQ==",
         "length": 32,
         "stub": true
       }
    }
     
   ## Expected Behavior
   Update function should consistetly return success code. 
   
   ## Current Behavior
   Update function return success code on about 50% of executions. 
   The other times it throws 412 'Precondition Failed' error with message 
'Invalid attachment stub in <doc_id> for <attachment_name>'. But the document 
is updated correctlly when inspected at the DB. 
   
   ## Possible Solution
   ?
   
   ## Steps to Reproduce (for bugs)
   Use couchdb v2.0.0 and nano js client to:
   1. Create and store a document with an inline text attachment. Attachment 
size does not matter.
   2. Create an update function that updates some document fields (not the 
attachment).
   3. Call the the update function to update the doc.
   4. On occasions, the nano client will throw error 412 'Precondition Failed' 
with message 'Invalid attachment stub in <doc_id> for <attachment_name>'. 
   
   ## Your Environment
   * Version used: couchdb v2.0.0
   * Browser Name and version: not relevant
   * Operating System and version (desktop or mobile): Linux
   
   
 
----------------------------------------------------------------
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