Repository navigation
crates/rcache: verify sha256 against bincache index, add tests - #158
Conversation
📝 WalkthroughWalkthroughThe changes add SHA-256 hash verification throughout the caching infrastructure to detect data integrity issues during remote cache materialization and file operations, along with corresponding error variants, a new utility method for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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.
🧹 Nitpick comments (1)
crates/rcache/src/remote.rs (1)
344-349: Make mock backend fail on missing fixtures instead of returning empty data.Defaulting to
Vec::new()can mask incorrect URL/key wiring in tests and still produce a hash mismatch for the wrong reason.Proposed test-hardening diff
async fn execute(&self, req: MockUrl) -> Result<MockResponse, std::io::Error> { - let data = self.responses.get(&req.0).cloned().unwrap_or_default(); + let data = self.responses.get(&req.0).cloned().ok_or_else(|| { + std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("missing mock response for {}", req.0), + ) + })?; Ok(MockResponse { data, consumed: false, }) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/rcache/src/remote.rs` around lines 344 - 349, The mock backend's execute method currently returns an empty MockResponse when a fixture is missing, which can hide test wiring bugs; update async fn execute(&self, req: MockUrl) -> Result<MockResponse, std::io::Error> to check self.responses.get(&req.0) and if absent return Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("no fixture for {}", req.0))) instead of defaulting to Vec::new(), otherwise construct and return the MockResponse with the found data and consumed: false; refer to the execute method, MockUrl, MockResponse and the responses map when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/rcache/src/remote.rs`:
- Around line 344-349: The mock backend's execute method currently returns an
empty MockResponse when a fixture is missing, which can hide test wiring bugs;
update async fn execute(&self, req: MockUrl) -> Result<MockResponse,
std::io::Error> to check self.responses.get(&req.0) and if absent return
Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("no fixture for
{}", req.0))) instead of defaulting to Vec::new(), otherwise construct and
return the MockResponse with the found data and consumed: false; refer to the
execute method, MockUrl, MockResponse and the responses map when making the
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ddf7bfad-066b-4924-8468-9044642ad65f
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
crates/common/src/file_cache.rscrates/common/src/lib.rscrates/rcache/Cargo.tomlcrates/rcache/src/remote.rs
Whelp. Looks like a refactor a while ago stopped using
FileCacheto fetch the artifact tarballs, andFileCachewas responsible for checking the sha's.This change restores sha checking, as well as adds adversarial tests to all the paths where we fetch artifacts that need hash checking.
Lets get this one in sooner rather than later.
Summary by CodeRabbit
Improvements
Tests