fix: circumvent genai sdk requirement for api key when using gateway auth via ACP (#23042)

This commit is contained in:
Sri Pasumarthi
2026-03-18 21:31:02 -07:00
committed by GitHub
parent 2009fbbd92
commit e9171fd792
2 changed files with 27 additions and 0 deletions

View File

@@ -725,6 +725,26 @@ describe('createContentGeneratorConfig', () => {
expect(config.apiKey).toBeUndefined();
expect(config.vertexai).toBeUndefined();
});
it('should configure for GATEWAY using dummy placeholder if GEMINI_API_KEY is set', async () => {
vi.stubEnv('GEMINI_API_KEY', 'env-gemini-key');
const config = await createContentGeneratorConfig(
mockConfig,
AuthType.GATEWAY,
);
expect(config.apiKey).toBe('gateway-placeholder-key');
expect(config.vertexai).toBe(false);
});
it('should configure for GATEWAY using dummy placeholder if GEMINI_API_KEY is not set', async () => {
vi.stubEnv('GEMINI_API_KEY', '');
vi.mocked(loadApiKey).mockResolvedValue(null);
const config = await createContentGeneratorConfig(
mockConfig,
AuthType.GATEWAY,
);
expect(config.apiKey).toBe('gateway-placeholder-key');
expect(config.vertexai).toBe(false);
});
});
describe('validateBaseUrl', () => {

View File

@@ -150,6 +150,13 @@ export async function createContentGeneratorConfig(
return contentGeneratorConfig;
}
if (authType === AuthType.GATEWAY) {
contentGeneratorConfig.apiKey = apiKey || 'gateway-placeholder-key';
contentGeneratorConfig.vertexai = false;
return contentGeneratorConfig;
}
return contentGeneratorConfig;
}