fix: remove .expect() calls in FailoverProvider::try_providers#156
fix: remove .expect() calls in FailoverProvider::try_providers#156ilblackdragon merged 3 commits intonearai:mainfrom
Conversation
Summary of ChangesHello @ztsalexey, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors error handling within the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR removes two .expect() calls from the FailoverProvider::try_providers method to comply with the project convention of never using .unwrap() or .expect() in production code. Both calls were logically unreachable due to constructor invariants, but could have caused panics if future refactoring violated those invariants.
Changes:
- Replaced
.expect("providers list is non-empty")with.ok_or_else()?for proper error propagation when selecting the oldest-cooled provider - Replaced
.expect("available providers list is non-empty")with.unwrap_or_else()to provide a fallback error when all providers fail
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request correctly replaces .expect() calls with non-panicking error handling, which improves the robustness of the FailoverProvider and aligns with a no-panic policy. The changes are well-reasoned and improve the code quality. I have one minor suggestion to improve the clarity of an error message in a theoretically unreachable code path, which could aid debugging if a bug ever makes that path reachable.
…i#155) Replace two .expect() calls with proper error propagation to comply with the project no-panic convention. Both were logically unreachable but would panic if invariants were broken by a future refactor. Closes nearai#155 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84e0f81 to
5d805b4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…i#156) * fix: remove .expect() calls in FailoverProvider::try_providers (nearai#155) Replace two .expect() calls with proper error propagation to comply with the project no-panic convention. Both were logically unreachable but would panic if invariants were broken by a future refactor. Closes nearai#155 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Illia Polosukhin <ilblackdragon@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…i#156) * fix: remove .expect() calls in FailoverProvider::try_providers (nearai#155) Replace two .expect() calls with proper error propagation to comply with the project no-panic convention. Both were logically unreachable but would panic if invariants were broken by a future refactor. Closes nearai#155 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Illia Polosukhin <ilblackdragon@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
.expect("providers list is non-empty")with.ok_or_else()?error propagation.expect("available providers list is non-empty")with.unwrap_or_else()fallback errorBoth were logically unreachable but violated the project no-panic convention.
Closes #155
Test plan
cargo test --lib llm::failover🤖 Generated with Claude Code