fix: return clear 400 for keyless writes instead of misleading sha256 error#168
Open
alukach wants to merge 2 commits into
Open
fix: return clear 400 for keyless writes instead of misleading sha256 error#168alukach wants to merge 2 commits into
alukach wants to merge 2 commits into
Conversation
… error
A PUT/DELETE to `/{account}/{product}` (no object key) was forwarded upstream
and rejected with the confusing "x-amz-content-sha256 header is invalid".
This happens easily with `aws s3 cp f s3://account/product` (no trailing
slash): the CLI uploads `f` as the object literally named `product`, so the
request carries a streaming-payload content-sha256 against a keyless path.
Short-circuit PUT/DELETE to a keyless path with a 400 InvalidRequest that
names the real cause — the missing object key — so callers stop chasing the
sha256 red herring.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Claude finished @alukach's task in 59s —— View job ✅ No blocking issues — safe to merge.
|
|
🚀 Latest commit deployed to https://source-data-proxy-pr-168.source-coop.workers.dev
|
Extract `extract_path_segments` and the new `is_keyless_write` predicate into a wasm-free `object_path` module so they can be unit-tested natively via the `#[path]` pattern already used by `tests/authz.rs` (the lib is `cdylib` with `[lib] test = false`). Adds `tests/object_path.rs` covering segment parsing, keyless PUT/DELETE, keyed writes, and the read / multi-object-delete cases that must not be flagged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Uploading to a product without an object key fails with a baffling error:
The sha256 header is a red herring. With no trailing slash, the AWS CLI can't
tell
private-bucketis a "folder", so it uploads the file as the objectliterally named
private-bucket— i.e. account=alukach, product=private-bucket,object key = empty. The proxy maps that keyless
/{account}/{product}path toa bucket-level request and forwards a
PUTwith a streaming (aws-chunked)payload to the bucket root. The upstream rejects a streaming-payload
x-amz-content-sha256on a keyless PUT, surfacing the confusing header complaint.Adding a trailing slash or the full key works (
s3://alukach/private-bucket/),but the error gives no hint as to why.
Fix
Short-circuit
PUT/DELETEto a keyless path (/{account}/{product}orshorter) with a clear
400 InvalidRequestthat names the real cause:POSTis intentionally left alone — keylessPOST /{account}/{product}?delete(multi-object delete) is a legitimate bucket-level operation.
Notes
fetch.[lib] test = false, so it can't beexercised by
cargo test. The guard is a one-line predicate over the existing,production-exercised
extract_path_segments.cargo fmt --check,cargo clippy --target wasm32-unknown-unknown -- -D warnings, andcargo testall pass.🤖 Generated with Claude Code