-
-
Notifications
You must be signed in to change notification settings - Fork 962
fix(management): refresh antigravity token for api-call $TOKEN$ #888
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
Conversation
Summary of ChangesHello @LTbinglingfeng, 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 integrates support for refreshing OAuth tokens for a new 'antigravity' authentication provider within the management API. It establishes the necessary configuration, implements the core logic for performing token refreshes via HTTP requests, and includes comprehensive unit tests to validate the refresh mechanism's correctness under various conditions, such as when tokens are expired or still valid. 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 support for refreshing 'antigravity' provider OAuth tokens within the api-call management endpoint. The changes include adding new constants for OAuth, logic to detect and refresh expired tokens, and corresponding unit tests.
My review has identified a critical security vulnerability due to hardcoded secrets. There are also a couple of other issues related to correctness and maintainability that should be addressed: a logic bug that could return an expired token, an ignored error when persisting the new token, and duplicated code.
The addition of tests is a great step towards ensuring the new functionality is robust.
| antigravityOAuthClientID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com" | ||
| antigravityOAuthClientSecret = "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" |
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.
Hardcoding secrets like antigravityOAuthClientID and antigravityOAuthClientSecret is a major security risk. These credentials should be loaded from a secure configuration source (e.g., environment variables, a secret manager) and not be committed to the source code. Additionally, these constants appear to be duplicates of those in internal/runtime/executor/antigravity_executor.go. This duplication should be avoided by centralizing the configuration and loading secrets securely.
| if h != nil && h.authManager != nil { | ||
| auth.LastRefreshedAt = now | ||
| auth.UpdatedAt = now | ||
| _, _ = h.authManager.Update(ctx, auth) |
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 error returned by h.authManager.Update(ctx, auth) is being ignored. If updating the auth store fails, the newly refreshed token will be lost, and the refresh logic will be executed again on the next request. This could lead to unnecessary token refreshes and potential rate limiting. The error should be at least logged to aid in debugging.
if _, err := h.authManager.Update(ctx, auth); err != nil {
log.Warnf("failed to persist refreshed antigravity token: %v", err)
}| func int64Value(raw any) int64 { | ||
| switch typed := raw.(type) { | ||
| case int: | ||
| return int64(typed) | ||
| case int32: | ||
| return int64(typed) | ||
| case int64: | ||
| return typed | ||
| case uint: | ||
| return int64(typed) | ||
| case uint32: | ||
| return int64(typed) | ||
| case uint64: | ||
| if typed > uint64(^uint64(0)>>1) { | ||
| return 0 | ||
| } | ||
| return int64(typed) | ||
| case float32: | ||
| return int64(typed) | ||
| case float64: | ||
| return int64(typed) | ||
| case json.Number: | ||
| if i, errParse := typed.Int64(); errParse == nil { | ||
| return i | ||
| } | ||
| case string: | ||
| if s := strings.TrimSpace(typed); s != "" { | ||
| if i, errParse := json.Number(s).Int64(); errParse == nil { | ||
| return i | ||
| } | ||
| } | ||
| } | ||
| return 0 | ||
| } |
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.
This int64Value function is very similar to one in internal/runtime/executor/antigravity_executor.go. The existing function returns (int64, bool) while this new one returns int64 (and 0 on failure). This duplication increases maintenance overhead. Please consider consolidating these functions into a shared utility package. If this new version is superior, it should replace the existing one to avoid having two different implementations.
No description provided.