Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(google-cli): stop random project fallback and require real OAuth projectId (#285)

Jack54b1d8c8dedf
diff --git a/open-sse/executors/antigravity.ts b/open-sse/executors/antigravity.ts
index 5a80b315d7..91ba8fc5fb 100644
--- a/open-sse/executors/antigravity.ts
+++ b/open-sse/executors/antigravity.ts
@@ -38,14 +38,11 @@ export class AntigravityExecutor extends BaseExecutor {
transformRequest(model, body, stream, credentials) {
const bodyProjectId = body?.project;
const credentialsProjectId = credentials?.projectId;
- const hasExplicitProject = !!(bodyProjectId || credentialsProjectId);
- const projectId = bodyProjectId || credentialsProjectId || this.generateProjectId();
-
- if (!hasExplicitProject) {
- console.warn(
- `[Antigravity] ⚠️ No projectId provided via body or credentials — using generated fallback "${projectId}". ` +
- `This may cause 404 errors if the account has no active GCP project. ` +
- `Ensure the OAuth token includes a valid project or the request includes a project field.`
+ const projectId = bodyProjectId || credentialsProjectId;
+
+ if (!projectId) {
+ throw new Error(
+ "Missing Google projectId for Antigravity account. Please reconnect OAuth so OmniRoute can fetch your real Cloud Code project (loadCodeAssist)."
);
}
@@ -128,12 +125,6 @@ export class AntigravityExecutor extends BaseExecutor {
}
}
- generateProjectId() {
- const adj = ["useful", "bright", "swift", "calm", "bold"][Math.floor(Math.random() * 5)];
- const noun = ["fuze", "wave", "spark", "flow", "core"][Math.floor(Math.random() * 5)];
- return `${adj}-${noun}-${crypto.randomUUID().slice(0, 5)}`;
- }
-
generateSessionId() {
return `-${Math.floor(Math.random() * 9_000_000_000_000_000_000)}`;
}
diff --git a/open-sse/translator/helpers/geminiHelper.ts b/open-sse/translator/helpers/geminiHelper.ts
index 8fe75e4688..2ae45b8d6a 100644
--- a/open-sse/translator/helpers/geminiHelper.ts
+++ b/open-sse/translator/helpers/geminiHelper.ts
@@ -126,15 +126,6 @@ export function generateSessionId() {
return `-${Math.floor(Math.random() * 9000000000000000000)}`;
}
-// Generate project ID
-export function generateProjectId() {
- const adjectives = ["useful", "bright", "swift", "calm", "bold"];
- const nouns = ["fuze", "wave", "spark", "flow", "core"];
- const adj = adjectives[Math.floor(Math.random() * adjectives.length)];
- const noun = nouns[Math.floor(Math.random() * nouns.length)];
- return `${adj}-${noun}-${crypto.randomUUID().slice(0, 5)}`;
-}
-
// Helper: Remove unsupported keywords recursively from object/array
function removeUnsupportedKeywords(obj, keywords) {
if (!obj || typeof obj !== "object") return;
diff --git a/open-sse/translator/request/openai-to-gemini.ts b/open-sse/translator/request/openai-to-gemini.ts
index 6db425a430..f6b62b3045 100644
--- a/open-sse/translator/request/openai-to-gemini.ts
+++ b/open-sse/translator/request/openai-to-gemini.ts
@@ -15,7 +15,6 @@ import {
tryParseJSON,
generateRequestId,
generateSessionId,
- generateProjectId,
cleanJSONSchemaForAntigravity,
} from "../helpers/geminiHelper.ts";
@@ -321,13 +320,11 @@ export function openaiToGeminiCLIRequest(model, body, stream) {
// Wrap Gemini CLI format in Cloud Code wrapper
function wrapInCloudCodeEnvelope(model, geminiCLI, credentials = null, isAntigravity = false) {
- const hasRealProject = !!credentials?.projectId;
- const projectId = credentials?.projectId || generateProjectId();
+ const projectId = credentials?.projectId;
- if (!hasRealProject) {
- console.warn(
- `[${isAntigravity ? "Antigravity" : "GeminiCLI"}] ⚠️ No projectId in credentials — using generated fallback "${projectId}". ` +
- `This may cause 404 errors. Ensure the OAuth token includes a valid GCP project.`
+ if (!projectId) {
+ throw new Error(
+ `${isAntigravity ? "Antigravity" : "GeminiCLI"} account is missing projectId. Reconnect OAuth to load your real Cloud Code project before sending requests.`
);
}
@@ -374,13 +371,11 @@ function wrapInCloudCodeEnvelope(model, geminiCLI, credentials = null, isAntigra
}
function wrapInCloudCodeEnvelopeForClaude(model, claudeRequest, credentials = null) {
- const hasRealProject = !!credentials?.projectId;
- const projectId = credentials?.projectId || generateProjectId();
+ const projectId = credentials?.projectId;
- if (!hasRealProject) {
- console.warn(
- `[Antigravity/Claude] ⚠️ No projectId in credentials — using generated fallback "${projectId}". ` +
- `This may cause 404 errors. Ensure the OAuth token includes a valid GCP project.`
+ if (!projectId) {
+ throw new Error(
+ "Antigravity/Claude account is missing projectId. Reconnect OAuth to load your real Cloud Code project before sending requests."
);
}