fix(diffguard-core): propagate GlobSetBuilder error instead of panicking#1607
Conversation
…ing (#1475) `compile_filter_globs` called `.expect()` on `GlobSetBuilder::build()`, which would panic on failure rather than returning an error from a function that already returns `Result<_, PathFilterError>`. Add a `PathFilterError::GlobSetBuild` variant and replace the `.expect()` with `.map_err(...)` so the failure is surfaced through the existing error path, matching how `Glob::new()` errors are handled above.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Summary
Fixes #1475.
compile_filter_globsindiffguard-core/src/check.rscalled.expect("globset build should succeed")onGlobSetBuilder::build(). That function already returnsResult<GlobSet, PathFilterError>, so a build failure was being turned into a panic instead of a propagated error — exactly the pattern this codebase is migrating away from (ADR-0404,rust.no_unwrap).Changes
PathFilterError::GlobSetBuild { source: globset::Error }variant.Ok(b.build().expect(...))withb.build().map_err(|source| PathFilterError::GlobSetBuild { source }), mirroring howGlob::new()errors are mapped two lines above.compile_filter_globs_rejects_invalidto cover the new variant (the test still asserts the invalid-glob path).In practice the build call rarely fails because each
Glob::new()is validated up front, but using.expect()on aResult-returning call is a latent panic and a code-smell — surfacing it asPathFilterError::GlobSetBuildlets callers handle the failure normally.Test plan
cargo build --workspace— cleancargo test -p diffguard-core— 141 + 6 tests passcargo clippy -p diffguard-core --all-targets -- -D warnings— cleancompile_filter_globs_rejects_invalidtest still passes (now exhaustive over both variants)Generated by Claude Code