Preserve headers in multipart stream uploads - #471
Conversation
📝 WalkthroughWalkthroughMultipart initiation now supports optional custom headers in async and sync APIs. Existing methods delegate to header-aware methods. Streamed uploads forward headers during initiation. Tests cover signed headers, metadata, content integrity, cleanup, and multipart boundaries. ChangesMultipart upload headers
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Bucket
participant S3
Client->>Bucket: Start streamed multipart upload with custom headers
Bucket->>Bucket: Merge headers into initiation request
Bucket->>S3: Send signed multipart initiation request
S3-->>Bucket: Return upload identifier
Bucket-->>Client: Continue multipart upload
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Brownian Motion (Brass)Recommendation: Refactor Summary: Fixes lost multipart headers; good direction, but watch API bloat and async test certainty Highlights
Unknowns
Next actions
Reflection questions
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
s3/src/bucket.rs (1)
1936-1948: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a documentation example to the sync
initiate_multipart_upload_with_headers.The sync
initiate_multipart_upload_with_headersat Line 1943 is a public API. Its doc comment (Lines 1936-1941) has prose only and no# Examplecode block, unlike the async twin at Lines 1879-1904. Add a short example, consistent with how other paired async/sync methods in this file present a single example that also demonstrates the#[cfg(feature = "sync")]variant (for example, see Lines 366-372).As per coding guidelines, "All public APIs should have documentation examples" for
**/*.rs.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@s3/src/bucket.rs` around lines 1936 - 1948, Add a concise Rustdoc # Example block to the public sync method initiate_multipart_upload_with_headers, following the async twin’s example and the paired async/sync documentation pattern elsewhere in the file. Include the #[cfg(feature = "sync")] variant in the same example so both API forms are demonstrated, without changing the method implementation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@s3/src/bucket.rs`:
- Around line 1912-1915: Update both async and sync
initiate_multipart_upload_with_headers flows to remove existing
request_bucket.extra_headers entries for every key in custom_headers before
extending them, ensuring request-level headers replace bucket-level values
rather than creating duplicates.
---
Nitpick comments:
In `@s3/src/bucket.rs`:
- Around line 1936-1948: Add a concise Rustdoc # Example block to the public
sync method initiate_multipart_upload_with_headers, following the async twin’s
example and the paired async/sync documentation pattern elsewhere in the file.
Include the #[cfg(feature = "sync")] variant in the same example so both API
forms are demonstrated, without changing the method implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Brownian Motion (Brass)Recommendation: Refactor Summary: Fixes header loss at multipart initiation; approach is sound but needs tighter validation Highlights
Unknowns
Next actions
Reflection questions
|
Problem
put_object_stream_builderaccepts per-upload metadata and headers, but drops them when the payload reachesCHUNK_SIZEand switches to multipart upload. S3 requires completed-object headers such as metadata, cache control, storage class, and SSE-S3/KMS configuration onCreateMultipartUpload.Solution
initiate_multipart_upload_with_headersAPI while preserving the existing method signatureCHUNK_SIZEThe request-scoped clone preserves the existing credential provider and client configuration without mutating shared bucket headers.
Fixes #472.
This follows the maintainer direction in #446 and is related to #408. The motivating consumer bug is brunojppb/turbo-cache-server#620.
Verification
cargo fmt --all -- --checkcargo test -p rust-s3 multipart_initiation_with_headers_sends_and_signs_object_configurationsync-native-tlsThe request test also verifies that metadata, cache control, and SSE-S3 are included in SigV4
SignedHeaderson multipart initiation.Summary by CodeRabbit
New Features
Bug Fixes
This change is