fix: preserve google vertex adc auth fallback

This commit is contained in:
Shakker
2026-04-29 18:12:07 +01:00
parent 1df1ee48c0
commit 587ce45ec9
2 changed files with 26 additions and 1 deletions

View File

@@ -70,7 +70,9 @@ export function resolveEnvApiKey(
return resolved;
}
}
return null;
if (normalized !== "google-vertex") {
return null;
}
}
if (normalized === "google-vertex") {

View File

@@ -827,6 +827,29 @@ describe("getApiKeyForModel", () => {
});
});
it("resolveEnvApiKey('google-vertex') keeps ADC fallback when manifest env candidates are empty", async () => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-google-adc-candidates-"));
const credentialsPath = path.join(tempDir, "adc.json");
await fs.writeFile(credentialsPath, "{}", "utf8");
try {
const resolved = resolveEnvApiKey(
"google-vertex",
{
GOOGLE_APPLICATION_CREDENTIALS: credentialsPath,
GOOGLE_CLOUD_LOCATION: "us-central1",
GOOGLE_CLOUD_PROJECT: "vertex-project",
} as NodeJS.ProcessEnv,
{ candidateMap: { "google-vertex": ["GOOGLE_CLOUD_API_KEY"] } },
);
expect(resolved?.apiKey).toBe("gcp-vertex-credentials");
expect(resolved?.source).toBe("gcloud adc");
} finally {
await fs.rm(tempDir, { recursive: true, force: true });
}
});
it("resolveEnvApiKey('anthropic-vertex') accepts GOOGLE_APPLICATION_CREDENTIALS with project_id", async () => {
await expectVertexAdcEnvApiKey({
provider: "anthropic-vertex",