Skip to content

feat(rust-client): Add file variant with more reliable batching#346

Merged
lcian merged 12 commits intomainfrom
lcian/feat/file-batching
Mar 2, 2026
Merged

feat(rust-client): Add file variant with more reliable batching#346
lcian merged 12 commits intomainfrom
lcian/feat/file-batching

Conversation

@lcian
Copy link
Copy Markdown
Member

@lcian lcian commented Mar 2, 2026

Currently, the many API doesn't take into account body sizes, but the server does.
This means that if a user tries to upload large objects using that API, operations would just fail as the server-side limit is enforced.

This adds a new variant to PutBody that represents a file, and special handling logic in the many API based on this variant that prevents PUT failures by inspecting the file size and falling back to single-object PUT requests when said size exceeds the limit.

Note that this is slightly on the conservative side, as we rely on the file size on the file system prior to compression.

Similar handling can be introduced in the future for the other variants of PutBody, which would necessary include buffering for streams.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (rust-client) Add file variant with more reliable batching by lcian in #346

🤖 This preview updates automatically when you update the PR.

@lcian lcian marked this pull request as ready for review March 2, 2026 09:29
@lcian lcian requested a review from a team as a code owner March 2, 2026 09:29
Comment thread clients/rust/src/many.rs Outdated
cursor[bot]

This comment was marked as outdated.

Comment thread clients/rust/src/many.rs Outdated
Comment thread clients/rust/src/many.rs Outdated
Copy link
Copy Markdown
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

We should also support this in Python, for completeness.

Comment thread clients/rust/src/many.rs Outdated
Comment thread clients/rust/src/put.rs Outdated
Comment thread clients/rust/src/put.rs
Comment thread clients/rust/src/many.rs Outdated
@lcian lcian merged commit 0e9b2d9 into main Mar 2, 2026
21 checks passed
@lcian lcian deleted the lcian/feat/file-batching branch March 2, 2026 13:29
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread clients/rust/src/put.rs
// _ => todo!("compression algorithms other than `zstd` are currently not supported"),
(None, PutBody::File(file)) => {
let stream = ReaderStream::new(file).boxed();
Body::wrap_stream(stream)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing BufReader for unbuffered file read path

Medium Severity

The (None, PutBody::File(file)) branch wraps the file directly in ReaderStream::new(file) without a BufReader, while the (Some(Compression::Zstd), PutBody::File(file)) branch correctly uses BufReader::new(file). Since tokio::fs::File dispatches every poll_read call to the blocking thread pool, skipping BufReader means each 4KB chunk triggers a separate thread pool dispatch. For large files, this roughly doubles the number of blocking dispatches compared to the buffered path.

Additional Locations (1)

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants