Repository navigation
crates/remote-{client,proto}: implement check RPC definitions - #161
Conversation
📝 WalkthroughWalkthroughRefactors Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Client as Remote Client
participant Compressor as TarZst Compressor
participant Server as Remote Server
User->>Client: call check(dir, args)
Client->>Compressor: compress directory -> tar.zst (streamable)
Client->>Server: send initial CheckRequest (client_id, filters, flags)
loop upload chunks
Client->>Server: send CheckMessage::Chunk(bytes)
end
Server->>Server: assemble archive & run checkers
alt success
Server->>Client: CheckResponse::Check(CheckObject + results)
Client->>User: emit mapped (CheckObj, Vec<CheckResult>)
else error
Server->>Client: CheckResponse::Error(message)
Client->>User: emit Error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/remote-client/src/lib.rs (1)
1030-1060: Add one explicit test for server-sideCheckResponse::Errorhandling.The success path is covered well, but the error branch in
Client::check(Line 497) is currently unexercised.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/remote-client/src/lib.rs` around lines 1030 - 1060, Add a test that exercises the error branch of Client::check by having the mock RemoteExecutionServiceServer send a CheckResponse::Error and asserting that client.check returns an Err; specifically, create a new #[tokio::test] that sets up a temp dir and a RemoteExecutionServiceServer which responds with CheckResponse::Error (matching the enum used in the CheckResponse handling inside Client::check) and then call Client::check (the method around Line 497) and assert the returned result is an error and contains the expected error message/variant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 446-455: The code panics because the result of the
tokio::task::spawn_blocking + and_then is unwrapped; change Client::check's
stream setup to propagate errors instead of calling unwrap by replacing the
final .unwrap() with proper error propagation (e.g., use ? or .map_err(...) and
return Err(Error::Other(...)) from Client::check). Specifically locate the
spawn_blocking block that produces `let file = tokio::task::spawn_blocking(move
|| -> Result<std::fs::File, Error> { ... }) .await .map_err(|e|
Error::Other(e.into())) .and_then(|r| r) .unwrap();` and modify it to return a
Result (remove unwrap), for example chain .await.map_err(...).and_then(|r| r)
and then use `?` to assign `file` or explicitly handle the Err to return from
Client::check so archive/build failures surface as an Error return instead of
panicking.
- Around line 501-519: The code silently "fails open" by treating unknown object
variants (c.obj.and_then(... ) => None => continue) and unrecognized verdicts (_
=> check::CheckVerdict::Skip) as benign; change this to surface protocol/parsing
errors instead: in the object match around c.obj and check_object::Msg, return
or propagate a descriptive error (not continue) when None is encountered so
malformed messages are rejected, and in the verdict mapping around
check_result::CheckVerdict::try_from(r.verdict) replace the wildcard arm with an
Err return (or map to a Result and propagate the error) so unknown/invalid
verdict values are reported rather than coerced to Skip; update the surrounding
function signatures (e.g., the iterator/map closure and its caller) to return
Result where needed so these errors can bubble up.
---
Nitpick comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 1030-1060: Add a test that exercises the error branch of
Client::check by having the mock RemoteExecutionServiceServer send a
CheckResponse::Error and asserting that client.check returns an Err;
specifically, create a new #[tokio::test] that sets up a temp dir and a
RemoteExecutionServiceServer which responds with CheckResponse::Error (matching
the enum used in the CheckResponse handling inside Client::check) and then call
Client::check (the method around Line 497) and assert the returned result is an
error and contains the expected error message/variant.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b68f545-716c-4cbb-9c45-f9a222674b55
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
crates/check/src/harness.rscrates/check/src/lib.rscrates/check/src/naming.rscrates/check/src/outputs.rscrates/check/src/profile.rscrates/remote-client/Cargo.tomlcrates/remote-client/src/lib.rscrates/remote-proto/build.rscrates/remote-proto/protos/res/check.protocrates/remote-proto/protos/res/remote_execution_service.proto
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 2 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
d37dff1 to
8fd0d18
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 492-536: The code currently swallows frames when msg.msg is None
in the stream loop (while let Some(msg) = rpc.next().await), which can hide
malformed responses; change the None => {} branch to return an error so the
caller fails fast (e.g., return Error::Other(anyhow!("missing/invalid
CheckResponse.msg").into())); update the match handling around
check_response::Msg and msg.msg to treat a missing top-level message as a
protocol error rather than silently continuing.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d2261a82-8ed9-4ebd-87b7-076797d6f384
📒 Files selected for processing (1)
crates/remote-client/src/lib.rs
There was a problem hiding this comment.
♻️ Duplicate comments (1)
crates/remote-client/src/lib.rs (1)
505-565:⚠️ Potential issue | 🟠 MajorFail fast on missing top-level
CheckResponse.msg.Line 564 still treats a malformed response frame as benign. That can drop protocol errors on the floor and let the caller observe partial success. Return an
Errthrough the channel here instead of continuing.Proposed fix
match msg.msg { Some(check_response::Msg::Error(e)) => { let _ = tx.unbounded_send(( check::CheckObj::Package(String::new()), Err(Error::Other(anyhow!("check failed: {}", e.msg).into())), )); break; } Some(check_response::Msg::Check(c)) => { let obj = match c.obj.and_then(|o| o.msg) { Some(check_object::Msg::Package(n)) => check::CheckObj::Package(n), Some(check_object::Msg::Profile(n)) => check::CheckObj::Profile(n), Some(check_object::Msg::Harness(n)) => check::CheckObj::Harness(n), None => { let _ = tx.unbounded_send(( check::CheckObj::Package(String::new()), Err(Error::Other( anyhow!("check response missing object").into(), )), )); break; } }; let check_results: Result<Vec<_>, Error> = c .results .into_iter() .map(|r| -> Result<check::CheckResult, Error> { let verdict = match check_result::CheckVerdict::try_from(r.verdict) { Ok(check_result::CheckVerdict::CvFail) => { check::CheckVerdict::Fail } Ok(check_result::CheckVerdict::CvFixed) => { check::CheckVerdict::Fixed } Ok(check_result::CheckVerdict::CvSkip) => { check::CheckVerdict::Skip } Ok(check_result::CheckVerdict::CvPass) => { check::CheckVerdict::Pass } Ok(check_result::CheckVerdict::CvUnspecified) | Err(_) => { return Err(Error::Other( anyhow!("invalid check verdict value {}", r.verdict) .into(), )); } }; Ok(check::CheckResult { check: r.check.into(), verdict, err: r.errors, }) }) .collect(); if tx.unbounded_send((obj, check_results)).is_err() { break; } } - None => {} + None => { + let _ = tx.unbounded_send(( + check::CheckObj::Package(String::new()), + Err(Error::Other( + anyhow!("malformed check response: missing message").into(), + )), + )); + break; + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/remote-client/src/lib.rs` around lines 505 - 565, The match arm handling msg.msg == None should not ignore a malformed top-level CheckResponse; in the match on msg.msg inside the message-processing loop (the branch after Some(check_response::Msg::Error) and Some(check_response::Msg::Check)), replace the current None => {} with logic that sends an Err down tx (e.g., tx.unbounded_send((check::CheckObj::Package(String::new()), Err(Error::Other(anyhow!("missing check response message").into())))) and then break so the caller receives the protocol error instead of continuing.
🧹 Nitpick comments (1)
crates/remote-client/src/lib.rs (1)
1010-1017: Broaden the request assertions in the new check test.This only checks
client_idandpackages, so regressions infiles_stream,filter_names,skip_checkers,profiles/harnesses, orremote_cache_gcs_bucketserialization would still pass.Suggested test expansion
let Msg::Request(req) = first.msg.unwrap() else { panic!("expected CheckRequest as first message"); }; assert!(!req.client_id.is_empty()); assert!(req.packages); + assert!(!req.profiles); + assert!(!req.harnesses); + assert_eq!(req.filter_names, Vec::<String>::new()); + assert_eq!(req.skip_checkers, Vec::<String>::new()); + assert_eq!(req.remote_cache_gcs_bucket, None); + let files_stream = req.files_stream.expect("expected files_stream"); + assert_eq!( + files_stream.kind, + i32::from(stream_config::StreamKind::SkWorktree) + ); + let format = files_stream.format.expect("expected files format"); + let stream_config::Format::Files(files) = format else { + panic!("expected files stream format"); + }; + let tarball = files.tarball.expect("expected tarball config"); + assert_eq!( + tarball.compression, + i32::from(TarballCompression::TarZst) + );Also applies to: 1076-1083
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/remote-client/src/lib.rs` around lines 1010 - 1017, The test only asserts req.client_id and req.packages; expand the assertions in the block that reads the first message (pattern matching Msg::Request(req)) to validate all important fields were serialized correctly: add explicit assertions checking req.files_stream (or its enum/option contents) matches the expected files stream, req.filter_names equals the expected filter_names vec, req.skip_checkers equals expected skip_checkers, req.profiles or req.harnesses matches the expected profiles/harnesses structure, and req.remote_cache_gcs_bucket equals the expected bucket string (and any nested fields); update any expected values used by the test setup and mirror this same expansion for the other occurrence around the second test block (the one similar at the later lines) to prevent regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 505-565: The match arm handling msg.msg == None should not ignore
a malformed top-level CheckResponse; in the match on msg.msg inside the
message-processing loop (the branch after Some(check_response::Msg::Error) and
Some(check_response::Msg::Check)), replace the current None => {} with logic
that sends an Err down tx (e.g.,
tx.unbounded_send((check::CheckObj::Package(String::new()),
Err(Error::Other(anyhow!("missing check response message").into())))) and then
break so the caller receives the protocol error instead of continuing.
---
Nitpick comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 1010-1017: The test only asserts req.client_id and req.packages;
expand the assertions in the block that reads the first message (pattern
matching Msg::Request(req)) to validate all important fields were serialized
correctly: add explicit assertions checking req.files_stream (or its enum/option
contents) matches the expected files stream, req.filter_names equals the
expected filter_names vec, req.skip_checkers equals expected skip_checkers,
req.profiles or req.harnesses matches the expected profiles/harnesses structure,
and req.remote_cache_gcs_bucket equals the expected bucket string (and any
nested fields); update any expected values used by the test setup and mirror
this same expansion for the other occurrence around the second test block (the
one similar at the later lines) to prevent regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 874a83fe-6c75-4da4-8344-a3acf44d98c3
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
crates/check/src/harness.rscrates/check/src/lib.rscrates/check/src/naming.rscrates/check/src/outputs.rscrates/check/src/profile.rscrates/remote-client/Cargo.tomlcrates/remote-client/src/lib.rscrates/remote-proto/build.rscrates/remote-proto/protos/res/check.protocrates/remote-proto/protos/res/remote_execution_service.proto
✅ Files skipped from review due to trivial changes (6)
- crates/remote-proto/build.rs
- crates/check/src/profile.rs
- crates/check/src/outputs.rs
- crates/check/src/harness.rs
- crates/remote-client/Cargo.toml
- crates/remote-proto/protos/res/check.proto
🚧 Files skipped from review as they are similar to previous changes (2)
- crates/remote-proto/protos/res/remote_execution_service.proto
- crates/check/src/naming.rs
Summary by CodeRabbit
New Features
Tests