Skip to content

fix(versionsource): surface version creation failures and fix streaming warning#250

Merged
kptdobe merged 1 commit intomainfrom
versionsource-response
Mar 12, 2026
Merged

fix(versionsource): surface version creation failures and fix streaming warning#250
kptdobe merged 1 commit intomainfrom
versionsource-response

Conversation

@kptdobe
Copy link
Contributor

@kptdobe kptdobe commented Mar 11, 2026

Two related bugs in POST /versionsource:

  1. Non-retryable streaming warning in Cloudflare Workers
    When putVersion sends an HTML body (piped from an S3 GET response) to R2 using If-None-Match: *, R2 can reject the PUT via Expect: 100-continue before reading the body. The S3 GET response stream is then left open and unconsumed, causing Cloudflare Workers to log:
    "An error was encountered in a non-retryable streaming request."
    Fix: cancel Body in putVersion's catch block so the underlying connection is properly closed.

  2. POST /versionsource silently returns 201 when no version was created putVersion uses If-None-Match: * to write the version snapshot. When R2 returns 412 (version UUID already stored, or a false-positive during Worker cold starts under batch load), the code treated 412 as acceptable and continued to the main document PUT, ultimately returning 201. This made it impossible for callers to detect that no version was written.
    The API contract for POST /versionsource is "create a version". If no version is created for any reason, the response must be an error.

Fix: track versionCreated in putObjectWithVersion and have postObjectVersionWithLabel return 500 when the version PUT did not produce a new snapshot. The main document PUT still runs on 412 (it bumps the version UUID), so a client retry will use a fresh UUID and succeed — matching observed behaviour where re-running the request on affected documents works correctly.

…ng warning

Two related bugs in POST /versionsource:

1. Non-retryable streaming warning in Cloudflare Workers
When putVersion sends an HTML body (piped from an S3 GET response) to R2
using If-None-Match: *, R2 can reject the PUT via Expect: 100-continue
before reading the body. The S3 GET response stream is then left open and
unconsumed, causing Cloudflare Workers to log:
  "An error was encountered in a non-retryable streaming request."
Fix: cancel Body in putVersion's catch block so the underlying connection
is properly closed.

2. POST /versionsource silently returns 201 when no version was created
putVersion uses If-None-Match: * to write the version snapshot. When R2
returns 412 (version UUID already stored, or a false-positive during
Worker cold starts under batch load), the code treated 412 as acceptable
and continued to the main document PUT, ultimately returning 201.
This made it impossible for callers to detect that no version was written.

The API contract for POST /versionsource is "create a version". If no
version is created for any reason, the response must be an error.

Fix: track versionCreated in putObjectWithVersion and have
postObjectVersionWithLabel return 500 when the version PUT did not
produce a new snapshot. The main document PUT still runs on 412 (it
bumps the version UUID), so a client retry will use a fresh UUID and
succeed — matching observed behaviour where re-running the request
on affected documents works correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kptdobe kptdobe requested review from bosschaert and karlpauls and removed request for karlpauls March 11, 2026 14:28
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bosschaert bosschaert requested a review from karlpauls March 11, 2026 15:12
@kptdobe kptdobe requested a review from bosschaert March 12, 2026 07:39
@kptdobe kptdobe merged commit 4ee0dbe into main Mar 12, 2026
9 of 10 checks passed
@kptdobe kptdobe deleted the versionsource-response branch March 12, 2026 07:39
adobe-bot pushed a commit that referenced this pull request Mar 12, 2026
## [1.1.7](v1.1.6...v1.1.7) (2026-03-12)

### Bug Fixes

* **versionsource:** surface version creation failures and fix streaming warning ([#250](#250)) ([4ee0dbe](4ee0dbe))
@adobe-bot
Copy link
Collaborator

🎉 This PR is included in version 1.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants