diff options
| author | Marat Boshernitsan <[email protected]> | 2025-07-08 09:37:10 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-08 16:37:10 +0000 |
| commit | f1647d9e19bf6930bc50bd2e66d2929f8f771503 (patch) | |
| tree | 9419cbc6345c775f4c3bf21a9437a1614cf8fc33 /packages/cli/src | |
| parent | 5c759d48c7e49b84f35544478d86cfe60a41b569 (diff) | |
Improve auth env var validation logic and messaging to detect settings that confuse GenAI SDK (#1381)
Co-authored-by: Scott Densmore <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/config/auth.test.ts | 6 | ||||
| -rw-r--r-- | packages/cli/src/config/auth.ts | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/packages/cli/src/config/auth.test.ts b/packages/cli/src/config/auth.test.ts index a4c0cf25..96defb1e 100644 --- a/packages/cli/src/config/auth.test.ts +++ b/packages/cli/src/config/auth.test.ts @@ -40,7 +40,7 @@ describe('validateAuthMethod', () => { it('should return an error message if GEMINI_API_KEY is not set', () => { expect(validateAuthMethod(AuthType.USE_GEMINI)).toBe( - 'GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!', + 'GEMINI_API_KEY environment variable not found. Add that to your environment and try again (no reload needed if using .env)!', ); }); }); @@ -59,10 +59,10 @@ describe('validateAuthMethod', () => { it('should return an error message if no required environment variables are set', () => { expect(validateAuthMethod(AuthType.USE_VERTEX_AI)).toBe( - 'Must specify GOOGLE_GENAI_USE_VERTEXAI=true and either:\n' + + 'When using Vertex AI, you must specify either:\n' + '• GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.\n' + '• GOOGLE_API_KEY environment variable (if using express mode).\n' + - 'Update your .env and try again, no reload needed!', + 'Update your environment and try again (no reload needed if using .env)!', ); }); }); diff --git a/packages/cli/src/config/auth.ts b/packages/cli/src/config/auth.ts index 0f97b4d5..91d4eee3 100644 --- a/packages/cli/src/config/auth.ts +++ b/packages/cli/src/config/auth.ts @@ -18,7 +18,7 @@ export const validateAuthMethod = (authMethod: string): string | null => { if (authMethod === AuthType.USE_GEMINI) { if (!process.env.GEMINI_API_KEY) { - return 'GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!'; + return 'GEMINI_API_KEY environment variable not found. Add that to your environment and try again (no reload needed if using .env)!'; } return null; } @@ -29,10 +29,10 @@ export const validateAuthMethod = (authMethod: string): string | null => { const hasGoogleApiKey = !!process.env.GOOGLE_API_KEY; if (!hasVertexProjectLocationConfig && !hasGoogleApiKey) { return ( - 'Must specify GOOGLE_GENAI_USE_VERTEXAI=true and either:\n' + + 'When using Vertex AI, you must specify either:\n' + '• GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.\n' + '• GOOGLE_API_KEY environment variable (if using express mode).\n' + - 'Update your .env and try again, no reload needed!' + 'Update your environment and try again (no reload needed if using .env)!' ); } return null; |
