fix(services): reduce panic-prone calls in exchange_rate.rs#701
Open
paul-itodo wants to merge 1 commit into
Open
fix(services): reduce panic-prone calls in exchange_rate.rs#701paul-itodo wants to merge 1 commit into
paul-itodo wants to merge 1 commit into
Conversation
…k#578) Replace all bare .unwrap() calls with .expect("message") throughout the file. Production Default impl retains a documented expect since BigDecimal::from_str cannot be const and Default::default cannot return Result. Test code uses .single().expect() for chrono UTC datetimes (always unambiguous) and descriptive expect messages for BigDecimal literal parses, preserving observability context on failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@paul-itodo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.unwrap()calls insrc/services/exchange_rate.rswith.expect("message")Defaultimpl retains a documented panic with an explicit message explaining the invariant (BigDecimal::from_str on a hardcoded literal; Default cannot return Result).single().expect()for chrono UTC datetimes and descriptive.expect()for BigDecimal literal parsesunwrap_or_elseusages are untouched (safe by design)Changes
src/services/exchange_rate.rs: 26.unwrap()→.expect("message"), covering production Default impl and all test helper callsAcceptance criteria met
Defaultimpl) is documented as an unrecoverable invariant that only fires if a hardcoded string literal is invalid — which would indicate a compile-time regressionCloses #578
Test plan
cargo test— all existing unit tests passcargo clippy— no new warnings🤖 Generated with Claude Code