Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Update Function throws occasional 412 errors when documents has inline attachments #584

Closed
ArikShifer opened this issue Jun 7, 2017 · 5 comments

Comments

@ArikShifer
Copy link

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:https://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
@wohali
Copy link
Member

wohali commented Jul 3, 2017

Hi @ArikShifer Are you able to test this against CouchDB master at all? We're finalising the list of bugs for fixing in 2.1 and need a reproducible test case for this against master if we're to consider this a blocker.

@ArikShifer
Copy link
Author

HI @wohali, unfortunately I cannot test against CouchDB master. My project is restricted to couchdb v2.0.0.

@moreiramarti
Copy link

Hi

Same issue here (also with 2.0.0).
Do you have any updates ?

Regards,
Martinho MOREIRA

@wohali
Copy link
Member

wohali commented Jul 28, 2017

@moreiramarti We need a reproducible test case.

@janl
Copy link
Member

janl commented Oct 1, 2017

Closing for inactivity. Please reopen with a reproducible test case.

@janl janl closed this as completed Oct 1, 2017
nickva pushed a commit to nickva/couchdb that referenced this issue Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants