fix: Improve error message for 401 / invalid API key (avoid "local ...#5808
Conversation
The previous error message mentioned "local model configuration" which could confuse users who don't use local models. The new message clearly directs users to check their API key and model access. Fixes FlowiseAI#5776
Summary of ChangesHello @bintocher, 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 aims to enhance the user experience by clarifying error messages related to 401 Unauthorized responses. It replaces a potentially confusing message about "local model configuration" with a more direct and helpful message that guides users to verify their API key and its access to the requested model, thereby streamlining troubleshooting for API key-related issues. 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.
Code Review
The pull request successfully improves the user-facing error message for 401 Unauthorized errors, making it more descriptive and actionable by removing confusing references to local model configuration. The changes are applied consistently across the error middleware and the SSE streamer. The primary improvement opportunity is to centralize the hardcoded strings to avoid duplication and improve maintainability.
| if (err.message.includes('401 Incorrect API key provided')) | ||
| err.message = '401 Invalid model key or Incorrect local model configuration.' | ||
| err.message = '401 Unauthorized – check your API key and ensure it has access to the requested model.' |
| if (msg.includes('401 Incorrect API key provided')) | ||
| msg = '401 Unauthorized – check your API key and ensure it has access to the requested model.' |
Summary
Improves the error message shown when a 401 Unauthorized error occurs due to an invalid or missing API key. The previous message mentioning "local model configuration" was confusing users, as this error typically indicates an API key issue rather than a local model configuration problem.
Issue
Fixes #5776
Changes
errorHandlerMiddlewarefrom "Invalid model key or Incorrect local model configuration" to "Unauthorized – check your API key and ensure it has access to the requested model"SSEStreamer.streamErrorEventfor consistency across both error handling pathsTesting