Skip to content

fix(aws_s3 sink): restrict checksum calculation to fix R2 InvalidRequest - #25803

Merged
thomasqueirozb merged 5 commits into
vectordotdev:masterfrom
Socialpranker:fix/23029-s3-r2-invalidrequest
Nov 21, 2026
Merged

thomasqueirozb merged 5 commits into
vectordotdev:masterfrom
Socialpranker:fix/23029-s3-r2-invalidrequest

Conversation

@Socialpranker

@Socialpranker Socialpranker commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

The S3 sink always attaches its own Content-MD5 header to every PutObject request. The AWS SDK for Rust separately defaults to calculating and attaching an x-amz-checksum-* request checksum on every request too, a behavior change described in awslabs/aws-sdk-rust#1240. Standard AWS S3 tolerates both headers at once, but Cloudflare R2 rejects the combination with InvalidRequest: You can only specify one non-default checksum at a time, which matches the debug output in this issue exactly (content-md5, x-amz-checksum-crc32, and x-amz-sdk-checksum-algorithm all present on the same request).

This restricts request_checksum_calculation to WhenRequired on the S3ClientBuilder used by both the aws_s3 sink and source, so the SDK stops adding its own checksum on top of Vector's existing Content-MD5. This is the exact setting AWS recommends for compatibility with S3-compatible providers, so AWS S3 behavior is unaffected while R2 (and similar services) should stop seeing the conflicting headers. response_checksum_validation is left at the SDK default, since the R2 failure is on the PutObject write path only, and weakening response validation would drop integrity checking on GetObject reads for no reason.

I verified this with a unit test that builds a client through S3ClientBuilder and asserts the resulting config carries WhenRequired for request checksum calculation, plus cargo check, cargo clippy, and cargo fmt on the touched crate, and the existing aws_s3 sink/source unit test suite (all passing). I don't have a Cloudflare R2 account, so I could not run this against a live R2 endpoint. Given the fix only removes headers the SDK adds unconditionally, and standard AWS S3 already supports WhenRequired, I'm fairly confident in the change. A user reported running this patch in production against v0.57.0 with no issues, but a real R2 smoke test from someone who hits this issue would still be a good confirmation before merge.

Fixes #23029

This PR was generated with Claude Opus 5, based on my own review of the issue thread and the S3 client construction code.

@Socialpranker
Socialpranker requested a review from a team as a code owner July 11, 2026 05:55
@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ghost

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f20194306

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/s3.rs Resolved
@Socialpranker

Copy link
Copy Markdown
Contributor Author

Good catch — pushed a fix. Restricted only request_checksum_calculation to WhenRequired; left response_checksum_validation at the SDK default since the R2 failure is on PutObject (write path), and weakening response validation would have dropped integrity checking on GetObject reads for no reason. Test updated accordingly.

@Socialpranker
Socialpranker force-pushed the fix/23029-s3-r2-invalidrequest branch from c1a8c6e to c8805ba Compare July 14, 2026 09:14
@Socialpranker

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@Socialpranker

Copy link
Copy Markdown
Contributor Author

Friendly ping — open since 11 July, CLA signed and checks green.

It restricts request_checksum_calculation to WhenRequired in the aws_s3 sink so PutObject stops sending the newer checksum headers that R2 rejects with InvalidRequest. response_checksum_validation is deliberately left at the SDK default, since the failure is on the write path and weakening response validation would drop integrity checking for everyone.

No urgency — happy to rebase or add coverage if that helps review.

@fedora-mwinters

Copy link
Copy Markdown

+1 this patch because we're now running it in production against v0.57.0.

@Socialpranker

Copy link
Copy Markdown
Contributor Author

@fedora-mwinters appreciate you confirming this holds up in prod on 0.57.0 — that's good real-world signal on top of the green checks, for whenever a maintainer gets a chance to look.

@Socialpranker
Socialpranker force-pushed the fix/23029-s3-r2-invalidrequest branch from c8805ba to d96e875 Compare August 20, 2026 13:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d96e8751df

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Socialpranker and others added 4 commits September 9, 2026 06:47
The AWS SDK for Rust defaults to always adding an x-amz-checksum-* request
checksum and validating response checksums (aws-sdk-rust#1240). Vector's S3
sink already sends its own explicit Content-MD5 header on every PutObject
request, so this SDK-added checksum is redundant against AWS S3, and
Cloudflare R2 rejects the combination outright with:

  InvalidRequest: You can only specify one non-default checksum at a time.

Set request_checksum_calculation and response_checksum_validation to
WhenRequired in S3ClientBuilder (shared by the aws_s3 sink and source),
matching AWS's own guidance for S3-compatible endpoints.

Verified with a unit test asserting the built client's config carries
WhenRequired for both settings, plus cargo check/clippy/fmt and the existing
aws_s3 sink/source unit test suite. Not verified against a live R2 endpoint
since no R2 credentials were available; the fix follows the exact mechanism
AWS documented for this incompatibility class.

Generated with Claude Opus 5.

Fixes vectordotdev#23029

Co-Authored-By: Claude Opus 5 <[email protected]>
…review

The original fix restricted both request_checksum_calculation and
response_checksum_validation to WhenRequired. Only the request side is
needed: the R2 InvalidRequest failure this PR fixes is caused by an
extra x-amz-checksum-* header on PutObject requests, which is a write
path. response_checksum_validation only affects reads (e.g. the aws_s3
source's GetObject calls), so leaving it at WhenRequired dropped the
SDK's default response integrity checking on downloads for AWS S3 with
no corresponding upside.

Leave response_checksum_validation at the SDK default and only restrict
request_checksum_calculation.

@thomasqueirozb thomasqueirozb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T00:16:22.171110Z 8233fa8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadoghq-integration datadoghq-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Restricting optional SDK request checksums preserves Vector’s Content-MD5 header and leaves download checksum validation unchanged. The completed static review identified no actionable regression.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 8233fa8

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8233fa8b4f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/common/s3.rs Resolved
@thomasqueirozb
thomasqueirozb added this pull request to the merge queue Nov 21, 2026
Merged via the queue into vectordotdev:master with commit 5542782 Nov 21, 2026
112 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidRequest error when using S3 sink to CloudFlare R2

3 participants