fix: treat versionsource 412 as success, eliminating ~860 500s/day#271
Merged
fix: treat versionsource 412 as success, eliminating ~860 500s/day#271
Conversation
When multiple concurrent POST /versionsource requests target the same document (e.g. the localization pipeline processing many locales in parallel), the second caller's R2 PUT for the version object gets a 412 PreconditionFailed because the first caller already wrote it with If-None-Match:*. The version IS in R2 — returning 500 "Version was not created" is incorrect. Fixes ~860 spurious 500 errors per 24h on /versionsource/adobecom/da-cc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bosschaert
approved these changes
Apr 30, 2026
adobe-bot
pushed a commit
that referenced
this pull request
Apr 30, 2026
Collaborator
|
🎉 This PR is included in version 1.7.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Worker logs show ~860
500responses per 24 hours, all fromPOST /versionsource/adobecom/da-cc/{locale}/…endpoints hit by the localization pipeline.Every entry has:
A subset also have:
Root cause
The localization pipeline processes many locales in parallel. Multiple concurrent workers read the same source document, all obtain the same
VersionUUID from the object's metadata, and all callPOST /versionsourcewith a label at the same moment.putVersionusesIf-None-Match: *to write the version object (so it can only be created once per key). The first caller wins and gets200. Every subsequent concurrent caller gets a412 PreconditionFailedfrom R2, because the version key already exists.In
putObjectWithVersion:Then in
postObjectVersionWithLabel:This returns
500even though the version was created — by the first concurrent request.Fix
Treat
412fromputVersionas "version already exists = created by a concurrent call":Test plan
putObjectWithVersion sets versionCreated true when version already existed (putVersion 412 = concurrent race)— updated to assertversionCreated === truepostObjectVersion returns 201 when version already exists in R2 (putVersion 412 concurrent race)— updated to expect201instead of500returns 201 when version PUT gets 412 (concurrent race — version already exists in R2)viapostObjectVersionWithLabel— verifies end-to-end that the caller gets201🤖 Generated with Claude Code