-
-
Notifications
You must be signed in to change notification settings - Fork 40
v6.6.48 #58
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
v6.6.48 #58
Conversation
docs(readme): add PackyCode sponsor
Refined header assignment to use `x-api-key` for Anthropic API requests, ensuring correct authorization behavior based on request attributes and URL validation.
Summary of ChangesHello @luispater, 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 introduces a new sponsor, PackyCode, by updating the project's README documentation to include their services and a promotional offer. Concurrently, it refines the integration with Claude's API by implementing a more flexible header management strategy, allowing the system to correctly apply Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a new sponsor section to the README files and updates the Claude executor to correctly use the x-api-key header for API key authentication with api.anthropic.com. This aligns with Anthropic's API standards. The changes to the Go code are functionally correct. I have provided one suggestion to improve the naming of a variable for better code clarity and long-term maintainability.
| useAPIKey := auth != nil && auth.Attributes != nil && strings.TrimSpace(auth.Attributes["api_key"]) != "" | ||
| isAnthropicBase := r.URL != nil && strings.EqualFold(r.URL.Scheme, "https") && strings.EqualFold(r.URL.Host, "api.anthropic.com") | ||
| if isAnthropicBase && useAPIKey { | ||
| r.Header.Del("Authorization") | ||
| r.Header.Set("x-api-key", apiKey) | ||
| } else { | ||
| r.Header.Set("Authorization", "Bearer "+apiKey) | ||
| } |
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.
For improved clarity and maintainability, the variable useAPIKey could be renamed to better reflect its purpose. It checks if the API key is provided via auth.Attributes, distinguishing it from an access token which can come from auth.Metadata. A name like isAPIKeyFromAttributes would be more descriptive.
This change makes it clearer that the logic switches the authentication header based on whether a direct API key is being used versus an OAuth token, especially when targeting the official Anthropic API endpoint.
| useAPIKey := auth != nil && auth.Attributes != nil && strings.TrimSpace(auth.Attributes["api_key"]) != "" | |
| isAnthropicBase := r.URL != nil && strings.EqualFold(r.URL.Scheme, "https") && strings.EqualFold(r.URL.Host, "api.anthropic.com") | |
| if isAnthropicBase && useAPIKey { | |
| r.Header.Del("Authorization") | |
| r.Header.Set("x-api-key", apiKey) | |
| } else { | |
| r.Header.Set("Authorization", "Bearer "+apiKey) | |
| } | |
| isAPIKeyFromAttributes := auth != nil && auth.Attributes != nil && strings.TrimSpace(auth.Attributes["api_key"]) != "" | |
| isAnthropicBase := r.URL != nil && strings.EqualFold(r.URL.Scheme, "https") && strings.EqualFold(r.URL.Host, "api.anthropic.com") | |
| if isAnthropicBase && isAPIKeyFromAttributes { | |
| r.Header.Del("Authorization") | |
| r.Header.Set("x-api-key", apiKey) | |
| } else { | |
| r.Header.Set("Authorization", "Bearer "+apiKey) | |
| } |
No description provided.