Merge pull request #294 from hijak/fix/google-cli-prefer-oauth-projectid

fix(google-cli): prefer OAuth projectId over request body project
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-03-10 23:32:59 -03:00
committed by GitHub
2 changed files with 17 additions and 2 deletions
+7 -1
View File
@@ -38,7 +38,13 @@ export class AntigravityExecutor extends BaseExecutor {
transformRequest(model, body, stream, credentials) {
const bodyProjectId = body?.project;
const credentialsProjectId = credentials?.projectId;
const projectId = bodyProjectId || credentialsProjectId;
const allowBodyProjectOverride = process.env.OMNIROUTE_ALLOW_BODY_PROJECT_OVERRIDE === "1";
// Default: prefer OAuth-stored projectId over incoming body.project to avoid
// stale/wrong client-side values causing 404/403 from Cloud Code endpoints.
// Opt-in escape hatch: set OMNIROUTE_ALLOW_BODY_PROJECT_OVERRIDE=1.
const projectId =
allowBodyProjectOverride && bodyProjectId ? bodyProjectId : credentialsProjectId || bodyProjectId;
if (!projectId) {
throw new Error(
+10 -1
View File
@@ -20,7 +20,16 @@ export class GeminiCLIExecutor extends BaseExecutor {
}
transformRequest(model, body, stream, credentials) {
if (!body.project && credentials?.projectId) {
const allowBodyProjectOverride = process.env.OMNIROUTE_ALLOW_BODY_PROJECT_OVERRIDE === "1";
// Default: prefer OAuth-stored projectId. Incoming body.project can be stale
// when clients cache older Cloud Code project values.
// Opt-in escape hatch: set OMNIROUTE_ALLOW_BODY_PROJECT_OVERRIDE=1.
if (allowBodyProjectOverride && body?.project) {
return body;
}
if (credentials?.projectId) {
body.project = credentials.projectId;
}
return body;