Skip to content

Conversation

@LTbinglingfeng
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Antigravity OAuth Integration: Introduced new constants for client ID, client secret, and token URL specifically for an 'antigravity' OAuth provider, enabling its integration into the system.
  • Token Refresh Logic Implementation: Developed a dedicated function, refreshAntigravityOAuthAccessToken, to manage the OAuth token refresh flow for the 'antigravity' provider. This function handles the HTTP request to the token endpoint, processes the response, and updates the authentication metadata with new token details and expiry information.
  • Conditional Token Resolution: Modified the resolveTokenForAuth function to intelligently determine if the authentication provider is 'antigravity' and, if so, to invoke the newly implemented token refresh logic to ensure API calls use valid and current tokens.
  • Comprehensive Unit Testing: Added a new test file, api_tools_test.go, which includes robust unit tests for the 'antigravity' token refresh mechanism. These tests cover scenarios such as successfully refreshing expired tokens and verifying that valid tokens are not unnecessarily refreshed, ensuring the reliability of the new functionality.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +37 to +38
antigravityOAuthClientID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com"
antigravityOAuthClientSecret = "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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)
        }

Comment on lines +462 to +495
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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@luispater luispater merged commit c1db2c7 into dev Jan 6, 2026
2 checks passed
@luispater luispater deleted the api-call-TOKEN-fix branch January 6, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants