Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ihan211
Copy link
Contributor

@ihan211 ihan211 commented May 1, 2025

  • Added log.Printf and fmt.Errorf in jokesFlow to log detailed errors.
  • Used an invalid API key to test error handling.
  • Updated context handling for graceful shutdown.

Tested with an invalid API key, producing:
Generate error: Error 400, Message: API key not valid...

Checklist (if applicable):

- 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.
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants