-
Notifications
You must be signed in to change notification settings - Fork 260
fix(go/genkit): expose detailed 4xx errors in googlegenai plugin #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add strict format validation to prevent silent 4xx errors - Add detailed error handling for HTTP status codes 400, 401, 403, 429, 500 - Fix issue where invalid API keys would fail with unhelpful errors - Document API's unusual behavior with invalid credentials
Remove unnecessary validation in favor of SDK's built-in validation. The Google AI and Vertex AI plugins now rely on the SDK to validate credentials, avoiding redundant validation steps. Add error formatting for better error messages. API errors are now properly formatted with clear, human-readable messages for common HTTP status codes. Ensure errors are properly propagated to callers instead of being swallowed. This makes debugging easier and provides better feedback to end users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore the changes in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove it. But the original won't take signal to exit by pressing Ctrl + C.
@@ -327,6 +327,7 @@ func generate( | |||
// Extract configuration to get the model version | |||
config, err := configFromRequest(input) | |||
if err != nil { | |||
// This is a local error from config parsing, not an API error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not needed (same for the rest of the comments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I add comments is to distinguish API error and none API error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
log.Printf
andfmt.Errorf
injokesFlow
to log detailed errors.Tested with an invalid API key, producing:
Generate error: Error 400, Message: API key not valid...
Checklist (if applicable):