Fix: error treatment model setup - #1632
Merged
MODSetter merged 2 commits intoJul 26, 2026
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
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
Improves the error feedback shown to users when setting up a model
connection — both when testing a model and when discovering available
models. Maps common provider failures (bad API key, rate limit) to
clearer, more actionable messages instead of surfacing raw upstream
errors.
Fix
The problem: When a model test or discovery failed, the UI often
surfaced the raw upstream provider error (e.g. a bare 400), which is
hard to interpret and doesn't guide the user toward a fix.
What changed:
model_connection_service.py_model_test_errornow maps a400containing "api key" to aclear
AUTH_FAILEDresult ("Authentication failed. Check yourcredentials and try again.") instead of a generic 400.
unavailable model, not just a transient throttle.
model_connections_routes.pypreview_connection_modelsreturns a friendlier hint("Try typing the model id manually.") when discovery fails, since
the next best action is manual entry.
Testing
error reads as an authentication failure, not a generic 400.
returns 400 with explicit direction
mentions quota / unavailable model.
High-level PR Summary
This PR improves error handling when users set up model connections by mapping common provider failures (invalid API keys, rate limits) to clearer, more actionable error messages. Instead of showing raw upstream errors like bare HTTP 400 responses, the system now provides specific guidance such as checking credentials for authentication failures or manually entering model IDs when automatic discovery fails. The changes enhance the user experience by making error feedback more interpretable and directing users toward concrete next steps.
⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_backend/app/services/model_connection_service.pysurfsense_backend/app/routes/model_connections_routes.py