Skip to content

Commit d06267a

Browse files
committed
docs(google-vertex): clarify auth gate, onboarding, and test contracts
Add inline comments at the three locations flagged by review: - env-api-keys.ts: explain the intentionally permissive auth gate and where invalid setups fail (request time, not gate time) - provider-contract-api.ts: document that onboarding writes are additive and reruns preserve existing models - model-auth.profiles.test.ts: explain why the missing-explicit-path rejection test still passes with env-vars-with-marker evidence
1 parent cd744a2 commit d06267a

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

extensions/google/provider-contract-api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export function createGoogleVertexProvider(): ProviderPlugin {
9696
? locationPrompt.trim()
9797
: VERTEX_DEFAULT_LOCATION;
9898

99+
// Onboarding writes are additive: env vars, marker profile, and
100+
// default model. Reruns preserve existing google-vertex models
101+
// via the configPatch merge below.
99102
return {
100103
profiles: [
101104
{

src/agents/model-auth.profiles.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,10 @@ describe("getApiKeyForModel", () => {
14571457
}
14581458
});
14591459

1460+
// The env-vars-with-marker evidence entry added for metadata-server ADC does
1461+
// not affect this test: resolveEnvApiKey uses precomputed authEvidenceMap from
1462+
// plugin manifests, and the test harness does not load the google plugin
1463+
// manifest, so only the local-file-with-env entry is evaluated.
14601464
it("resolveEnvApiKey('google-vertex') rejects missing explicit ADC path before fallback paths", async () => {
14611465
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-google-adc-home-"));
14621466
const fallbackDir = path.join(homeDir, ".config", "gcloud");

src/llm/env-api-keys.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ export function getEnvApiKey(provider: string): string | undefined {
235235
);
236236
const hasCredentialsEnv = Boolean(getEnvValue("GOOGLE_APPLICATION_CREDENTIALS"));
237237

238+
// Intentionally permissive: any signal of GCP intent passes the gate.
239+
// Actual credential resolution happens at request time in vertex-adc.ts.
240+
// Invalid setups (e.g. stale GOOGLE_APPLICATION_CREDENTIALS path with
241+
// project env) will fail with a GoogleAuth error, not "No API key found."
238242
if (hasProject || hasCredentials || hasCredentialsEnv) {
239243
return "<authenticated>";
240244
}

0 commit comments

Comments
 (0)