Skip to content

refactor: handle errors instead of panicking with unwrap in non-test code#619

Merged
notheotherben merged 2 commits into
mainfrom
refactor/remove-unwrap-non-test
Jul 8, 2026
Merged

refactor: handle errors instead of panicking with unwrap in non-test code#619
notheotherben merged 2 commits into
mainfrom
refactor/remove-unwrap-non-test

Conversation

@notheotherben

Copy link
Copy Markdown
Member

Summary

Removes every .unwrap() from non-test code, replacing each with proper error handling so failures surface as human-readable errors instead of panics. The remaining .unwrap() calls are all inside #[cfg(test)] modules.

Changes

  • src/sources/github_repo.rs & src/sources/github_gist.rs: Moved the fallible from and recovery parsing inside the try_stream! block so parse errors propagate through the Result stream via ? instead of unwrapping. The recovery-mode parse now uses a match that returns the default when unset and yields the parse error otherwise.
  • src/sources/github_releases.rs: Moved the target parse into the stream! block (yielding the error and returning on failure), and replaced two if let Err(...) { … } … .unwrap() patterns with match expressions.
  • src/pairing.rs: Replaced join_next().await.unwrap().unwrap() and fut.unwrap() with match arms that yield task results and convert a tokio::task::JoinError (from a panicked/cancelled backup task) into a human_errors::Error.
  • src/errors.rs: Added a HumanizableError implementation for tokio::task::JoinError, following the existing pattern.

Testing

  • cargo check --all-targets passes.
  • cargo test passes for all 151 tests, except one pre-existing live-network integration test (get_releases::case_1) that hit a GitHub API rate limit (403). Notably, the refactor correctly propagated that 403 as a proper error through the stream rather than panicking internally.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.43%. Comparing base (90c5373) to head (f3a497b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/errors.rs 0.00% 7 Missing ⚠️
src/main.rs 0.00% 3 Missing ⚠️
src/sources/github_gist.rs 0.00% 1 Missing ⚠️
src/sources/github_repo.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #619      +/-   ##
==========================================
- Coverage   75.35%   74.43%   -0.93%     
==========================================
  Files          31       31              
  Lines        2447     2394      -53     
==========================================
- Hits         1844     1782      -62     
- Misses        603      612       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…code

Replaces every .unwrap() in non-test code with proper error handling so that failures surface as human-readable errors instead of panics:

- Sources (repo/gist/releases): move the fallible 'from' and 'recovery' parsing into the stream so parse errors propagate through the Result stream instead of unwrapping.
- Releases: replace error-check-then-unwrap patterns with match expressions.
- Pairing engine: convert tokio JoinError from completed backup tasks into a human_errors::Error instead of unwrapping.
- Add a HumanizableError impl for tokio::task::JoinError.
@notheotherben notheotherben force-pushed the refactor/remove-unwrap-non-test branch from 2cec733 to f3a497b Compare July 8, 2026 09:38
@notheotherben notheotherben enabled auto-merge July 8, 2026 09:39
@notheotherben notheotherben merged commit 76d9954 into main Jul 8, 2026
9 checks passed
@notheotherben notheotherben deleted the refactor/remove-unwrap-non-test branch July 8, 2026 09:39
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.

1 participant