{"record":{"id":"273998f172046ae7","repo":"eyaltoledano/claude-task-master","slug":"vertex-ai-requires-authentication-provide-one-of","errorCode":null,"errorMessage":"Vertex AI requires authentication. Provide one of the following:\n  • GOOGLE_API_KEY environment variable (typical for API-based auth), OR\n  • GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file (recommended for production)","messagePattern":"Vertex AI requires authentication\\. Provide one of the following:\n  • GOOGLE_API_KEY environment variable \\(typical for API-based auth\\), OR\n  • GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file \\(recommended for production\\)","errorType":"validation","errorClass":"VertexAuthError","httpStatus":null,"severity":"critical","filePath":"src/ai-providers/google-vertex.js","lineNumber":94,"sourceCode":"\t\t\treturn value.trim().length > 0;\n\t\t}\n\t\treturn typeof value === 'object';\n\t}\n\n\t/**\n\t * Validates Vertex AI-specific authentication parameters\n\t * @param {object} params - Parameters to validate\n\t * @throws {VertexAuthError|VertexConfigError}\n\t */\n\tvalidateAuth(params) {\n\t\tconst { apiKey, projectId, location, credentials } = params;\n\n\t\t// Check for API key OR service account credentials\n\t\tconst hasValidApiKey = this.isValidCredential(apiKey);\n\t\tconst hasValidCredentials = this.isValidCredential(credentials);\n\n\t\tif (!hasValidApiKey && !hasValidCredentials) {\n\t\t\tthrow new VertexAuthError(\n\t\t\t\t'Vertex AI requires authentication. Provide one of the following:\\n' +\n\t\t\t\t\t'  • GOOGLE_API_KEY environment variable (typical for API-based auth), OR\\n' +\n\t\t\t\t\t'  • GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file (recommended for production)'\n\t\t\t);\n\t\t}\n\n\t\t// Project ID is required for Vertex AI\n\t\tif (\n\t\t\t!projectId ||\n\t\t\t(typeof projectId === 'string' && projectId.trim().length === 0)\n\t\t) {\n\t\t\tthrow new VertexConfigError(\n\t\t\t\t'Google Cloud project ID is required for Vertex AI. Set VERTEX_PROJECT_ID environment variable.'\n\t\t\t);\n\t\t}\n\n\t\t// Location is required for Vertex AI\n\t\tif (","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/google-vertex.js#L76-L112","documentation":"GoogleVertexProvider.validateAuth requires either a Google API key (GOOGLE_API_KEY) or service-account credentials (GOOGLE_APPLICATION_CREDENTIALS pointing to a JSON key file). VertexAuthError is thrown when neither a valid API key nor valid credentials can be found, so the provider cannot authenticate to Vertex AI.","triggerScenarios":"Instantiating or calling the Vertex provider when both isValidCredential(apiKey) and isValidCredential(credentials) are false — e.g. no GOOGLE_API_KEY set and no GOOGLE_APPLICATION_CREDENTIALS or invalid/empty credential file path.","commonSituations":"Running locally without gcloud auth or ADC configured; CI environment missing the secret; credentials JSON file path typo'd; env vars set on a machine but not inside a container's environment.","solutions":["Set GOOGLE_APPLICATION_CREDENTIALS to the absolute path of a service account JSON key file (recommended for production)","Or set GOOGLE_API_KEY in the environment for API-key-based auth","Run 'gcloud auth application-default login' for local development","Verify the credential file exists and is readable, and that env vars are passed into the container/CI job"],"exampleFix":"// before\n# no auth configured\nnode app.js\n// after\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json\nnode app.js","handlingStrategy":"validation","validationCode":"function assertVertexAuth() {\n  const hasApiKey = !!process.env.GOOGLE_API_KEY;\n  const credsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n  const hasCreds = !!credsPath && fs.existsSync(credsPath);\n  if (!hasApiKey && !hasCreds) {\n    throw new Error('Vertex AI auth missing: set GOOGLE_API_KEY or GOOGLE_APPLICATION_CREDENTIALS (valid file path)');\n  }\n}","typeGuard":"null","tryCatchPattern":"try {\n  await vertexProvider.generateText({ messages, modelId });\n} catch (e) {\n  if (e.name === 'VertexAuthError' || /Vertex AI requires authentication/.test(e.message)) {\n    console.error('Configure GOOGLE_API_KEY or GOOGLE_APPLICATION_CREDENTIALS before retrying');\n  } else throw e;\n}","preventionTips":["Check auth env vars at app startup with a fail-fast preflight check","In CI/containers, explicitly pass GOOGLE_API_KEY or the credentials file secret","Validate GOOGLE_APPLICATION_CREDENTIALS points to an existing readable JSON file"],"tags":["authentication","google-cloud","env-vars","vertex-ai"],"backgroundTag":"missing-credentials","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}