fix(minimal): bound the workspace-upload unpack-error buffer - #928
Conversation
`Client::upload_workspace_files` reads the upload channel to its close (the daemon's completion ack) and relays any unpack failure carried on extended-data stream 1, but it accumulated that stream into an unbounded `Vec`. A daemon spraying extended data could balloon the client's memory. Accumulate through the existing `append_daemon_error` helper instead, so the workspace upload shares the 64 KiB `DAEMON_ERROR_MAX` cap that the diagnostic-bundle download already enforces — the same "server acks first, client drains to close" pattern. Adds a client-side regression test that an upload targeting an unknown session surfaces as `Err` rather than a silent success, and a unit test that the error accumulator is capped. Closes #824 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesWorkspace upload error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@crates/minimal/tests/cli.rs`:
- Around line 314-320: Update the test around upload_workspace_files to assert
that the returned error contains the daemon-side “daemon failed to unpack
project files” prefix from the client error path, rather than only checking
result.is_err(). Preserve the unknown-session scenario and ensure unrelated
preparation or channel I/O errors do not satisfy the assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8e2c1ffd-dd09-4c52-a519-f6615acc8366
📒 Files selected for processing (2)
crates/minimal/src/client.rscrates/minimal/tests/cli.rs
| let result = client | ||
| .upload_workspace_files(SessionId::nil(), project.path()) | ||
| .await; | ||
| assert!( | ||
| result.is_err(), | ||
| "upload to an unknown session must fail, not report success: {result:?}" | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the daemon-side error, not merely any error.
This can pass if upload preparation or channel I/O fails before the daemon reports its unpack error. Assert the daemon failed to unpack project files prefix emitted by crates/minimal/src/client.rs.
Suggested assertion
- assert!(
- result.is_err(),
- "upload to an unknown session must fail, not report success: {result:?}"
- );
+ let err = result.expect_err("upload to an unknown session must fail");
+ assert!(
+ err.to_string()
+ .contains("daemon failed to unpack project files"),
+ "expected daemon unpack failure, got: {err:#}"
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let result = client | |
| .upload_workspace_files(SessionId::nil(), project.path()) | |
| .await; | |
| assert!( | |
| result.is_err(), | |
| "upload to an unknown session must fail, not report success: {result:?}" | |
| ); | |
| let err = result.expect_err("upload to an unknown session must fail"); | |
| assert!( | |
| err.to_string() | |
| .contains("daemon failed to unpack project files"), | |
| "expected daemon unpack failure, got: {err:#}" | |
| ); |
🤖 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 `@crates/minimal/tests/cli.rs` around lines 314 - 320, Update the test around
upload_workspace_files to assert that the returned error contains the
daemon-side “daemon failed to unpack project files” prefix from the client error
path, rather than only checking result.is_err(). Preserve the unknown-session
scenario and ensure unrelated preparation or channel I/O errors do not satisfy
the assertion.
Bound the workspace-upload unpack-error buffer in
Client.upload_workspace_fileserr.extend_from_slice(&data)) withappend_daemon_error, capping the buffer atDAEMON_ERROR_MAXduring workspace-file uploads.DAEMON_ERROR_MAXdoc comment to reflect that the cap applies to all streaming RPCs that buffer daemon errors, not just diagnostic-bundle downloads.Macroscope summarized a6d8264.
Summary by CodeRabbit