From 008e4804a6a6b971b426665f24ab8c676b9a1c5e Mon Sep 17 00:00:00 2001 From: riftzen-bit Date: Mon, 2 Mar 2026 17:31:17 -0800 Subject: [PATCH] fix(gemini-cli-auth): use PLATFORM_UNSPECIFIED for Linux in loadCodeAssist Google's loadCodeAssist API rejects "LINUX" as an invalid Platform enum value, causing OAuth setup to fail with 400 Bad Request on Linux systems. The pi-ai runtime already uses "PLATFORM_UNSPECIFIED" for this field. This aligns the extension's discoverProject() with that approach by returning "PLATFORM_UNSPECIFIED" for Linux (and other non-Windows/macOS platforms) instead of "LINUX". Also fixes the original resolvePlatform() which incorrectly fell through to "MACOS" as default instead of explicitly checking for "darwin". --- extensions/google-gemini-cli-auth/oauth.test.ts | 9 +++++---- extensions/google-gemini-cli-auth/oauth.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/extensions/google-gemini-cli-auth/oauth.test.ts b/extensions/google-gemini-cli-auth/oauth.test.ts index afc0971b16e..cec301a13e7 100644 --- a/extensions/google-gemini-cli-auth/oauth.test.ts +++ b/extensions/google-gemini-cli-auth/oauth.test.ts @@ -239,14 +239,15 @@ describe("loginGeminiCliOAuth", () => { "GOOGLE_CLOUD_PROJECT_ID", ] as const; - function getExpectedPlatform(): "WINDOWS" | "MACOS" | "LINUX" { + function getExpectedPlatform(): "WINDOWS" | "MACOS" | "LINUX" | "PLATFORM_UNSPECIFIED" { if (process.platform === "win32") { return "WINDOWS"; } - if (process.platform === "linux") { - return "LINUX"; + if (process.platform === "darwin") { + return "MACOS"; } - return "MACOS"; + // Matches updated resolvePlatform() which uses PLATFORM_UNSPECIFIED for Linux + return "PLATFORM_UNSPECIFIED"; } function getRequestUrl(input: string | URL | Request): string { diff --git a/extensions/google-gemini-cli-auth/oauth.ts b/extensions/google-gemini-cli-auth/oauth.ts index 7e2280b9c9f..4f8f2938e47 100644 --- a/extensions/google-gemini-cli-auth/oauth.ts +++ b/extensions/google-gemini-cli-auth/oauth.ts @@ -224,14 +224,16 @@ function generatePkce(): { verifier: string; challenge: string } { return { verifier, challenge }; } -function resolvePlatform(): "WINDOWS" | "MACOS" | "LINUX" { +function resolvePlatform(): "WINDOWS" | "MACOS" | "LINUX" | "PLATFORM_UNSPECIFIED" { if (process.platform === "win32") { return "WINDOWS"; } - if (process.platform === "linux") { - return "LINUX"; + if (process.platform === "darwin") { + return "MACOS"; } - return "MACOS"; + // Google's loadCodeAssist API rejects "LINUX" as an invalid Platform enum value. + // Use "PLATFORM_UNSPECIFIED" for Linux and other platforms to match the pi-ai runtime. + return "PLATFORM_UNSPECIFIED"; } async function fetchWithTimeout(