Skip to content

fix(antigravity): align Client-Metadata platform/identity with Antigravity requests#1578

Closed
happycastle114 wants to merge 6 commits intorouter-for-me:mainfrom
happycastle114:fix/antigravity-metadata-alignment
Closed

fix(antigravity): align Client-Metadata platform/identity with Antigravity requests#1578
happycastle114 wants to merge 6 commits intorouter-for-me:mainfrom
happycastle114:fix/antigravity-metadata-alignment

Conversation

@happycastle114
Copy link

@happycastle114 happycastle114 commented Feb 13, 2026

Summary

This patch aligns Antigravity metadata identity fields across auth requests.

Changes

  • Replaced static Client-Metadata JSON (IDE_UNSPECIFIED / PLATFORM_UNSPECIFIED) with dynamic Antigravity metadata.
  • Client-Metadata now uses:
    • ideType: ANTIGRAVITY
    • platform: WINDOWS on Windows, otherwise MACOS
    • pluginType: GEMINI
  • Updated load/onboard request body metadata to use the same dynamic platform mapping.

Why

Recent Antigravity interop updates require consistent identity/platform signaling. This avoids mixed metadata values between headers and request body.

Notes

  • No secrets or environment-specific endpoints are included.
  • Could not run go test in this environment because Go toolchain is unavailable (go: command not found).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @happycastle114, 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 refactors the Antigravity authentication mechanism to dynamically generate client metadata, ensuring consistent platform and identity signaling across various requests. This change is crucial for maintaining compatibility with recent Antigravity interop updates, preventing discrepancies between header and request body metadata.

Highlights

  • Dynamic Client Metadata: Replaced static JSON for Client-Metadata and request body metadata with dynamically generated values.
  • Platform Detection: The platform field in Client-Metadata and request bodies now dynamically detects the operating system, reporting "WINDOWS" for Windows and "MACOS" otherwise.
  • Antigravity Interop Consistency: Ensured consistent identity and platform signaling between headers and request bodies to meet recent Antigravity interop requirements.

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

Changelog
  • internal/auth/antigravity/auth.go
    • Replaced static metadata map with antigravityRequestMetadata() for loadReqBody in FetchProjectID.
    • Replaced ClientMetadata constant with antigravityJSONClientMetadata() for Client-Metadata header in FetchProjectID.
    • Replaced static metadata map with antigravityRequestMetadata() for requestBody in OnboardUser.
    • Replaced ClientMetadata constant with antigravityJSONClientMetadata() for Client-Metadata header in OnboardUser.
  • internal/auth/antigravity/constants.go
    • Added fmt and runtime package imports.
    • Removed the ClientMetadata constant.
    • Added runtimeMetadataPlatform() function to determine the OS.
    • Added antigravityJSONClientMetadata() function to generate JSON client metadata dynamically.
    • Added antigravityRequestMetadata() function to generate map-based request metadata dynamically.
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 correctly centralizes the generation of Antigravity metadata, replacing hardcoded values with dynamic ones. This improves consistency between request headers and bodies. I've identified a couple of areas for improvement in the new implementation. The platform detection logic is not fully robust and could misidentify operating systems like Linux. Additionally, there's an opportunity to refactor the new helper functions to eliminate code duplication and a minor inefficiency. My review comments provide specific suggestions to address these points.

Comment on lines 40 to 45
func runtimeMetadataPlatform() string {
if runtime.GOOS == "windows" {
return "WINDOWS"
}
return "MACOS"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current implementation for runtimeMetadataPlatform is not robust. It correctly identifies Windows, but incorrectly classifies all other operating systems, including Linux, as MACOS. Given that the APIClient constant suggests usage in vscode_cloudshelleditor, which is a Linux environment, this will lead to incorrect platform reporting.

It would be better to use a switch statement on runtime.GOOS to explicitly handle different supported operating systems. For macOS, the value of runtime.GOOS is "darwin". I suggest handling linux explicitly and adding a default case to fall back to PLATFORM_UNSPECIFIED for any other OS, which was the value used prior to this change.

func runtimeMetadataPlatform() string {
	switch runtime.GOOS {
	case "windows":
		return "WINDOWS"
	case "darwin":
		return "MACOS"
	case "linux":
		return "LINUX"
	default:
		return "PLATFORM_UNSPECIFIED"
	}
}

Comment on lines 47 to 57
func antigravityJSONClientMetadata() string {
return fmt.Sprintf(`{"ideType":"ANTIGRAVITY","platform":"%s","pluginType":"GEMINI"}`, runtimeMetadataPlatform())
}

func antigravityRequestMetadata() map[string]string {
return map[string]string{
"ideType": "ANTIGRAVITY",
"platform": runtimeMetadataPlatform(),
"pluginType": "GEMINI",
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is some duplication between antigravityJSONClientMetadata and antigravityRequestMetadata. Both functions construct similar metadata structures and call runtimeMetadataPlatform(). In functions like FetchProjectID, both helpers are called, resulting in runtimeMetadataPlatform() being executed twice, which is slightly inefficient.

To improve this, you could determine the platform once at package initialization and store it in a package-level variable. This variable can then be reused in both helper functions, making the code more efficient and adhering to the Don't Repeat Yourself (DRY) principle.

var platform = runtimeMetadataPlatform()

func antigravityJSONClientMetadata() string {
	return fmt.Sprintf("{\"ideType\":\"ANTIGRAVITY\",\"platform\":\"%s\",\"pluginType\":\"GEMINI\"}", platform)
}

func antigravityRequestMetadata() map[string]string {
	return map[string]string{
		"ideType":    "ANTIGRAVITY",
		"platform":   platform,
		"pluginType": "GEMINI",
	}
}

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.

1 participant