eyaltoledano/claude-task-master · critical · VertexAuthError
Vertex AI requires authentication. Provide one of the follow
Error message
Vertex AI requires authentication. Provide one of the following: • GOOGLE_API_KEY environment variable (typical for API-based auth), OR • GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file (recommended for production)
What it means
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.
Source
Thrown at src/ai-providers/google-vertex.js:94
return value.trim().length > 0;
}
return typeof value === 'object';
}
/**
* Validates Vertex AI-specific authentication parameters
* @param {object} params - Parameters to validate
* @throws {VertexAuthError|VertexConfigError}
*/
validateAuth(params) {
const { apiKey, projectId, location, credentials } = params;
// Check for API key OR service account credentials
const hasValidApiKey = this.isValidCredential(apiKey);
const hasValidCredentials = this.isValidCredential(credentials);
if (!hasValidApiKey && !hasValidCredentials) {
throw new VertexAuthError(
'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)'
);
}
// Project ID is required for Vertex AI
if (
!projectId ||
(typeof projectId === 'string' && projectId.trim().length === 0)
) {
throw new VertexConfigError(
'Google Cloud project ID is required for Vertex AI. Set VERTEX_PROJECT_ID environment variable.'
);
}
// Location is required for Vertex AI
if (View on GitHub (pinned to c0c98d367c)
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
Example fix
// before # no auth configured node app.js // after export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json node app.js
Defensive patterns
Strategy: validation
Validate before calling
function assertVertexAuth() {
const hasApiKey = !!process.env.GOOGLE_API_KEY;
const credsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
const hasCreds = !!credsPath && fs.existsSync(credsPath);
if (!hasApiKey && !hasCreds) {
throw new Error('Vertex AI auth missing: set GOOGLE_API_KEY or GOOGLE_APPLICATION_CREDENTIALS (valid file path)');
}
} Type guard
null
Try / catch
try {
await vertexProvider.generateText({ messages, modelId });
} catch (e) {
if (e.name === 'VertexAuthError' || /Vertex AI requires authentication/.test(e.message)) {
console.error('Configure GOOGLE_API_KEY or GOOGLE_APPLICATION_CREDENTIALS before retrying');
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Google Cloud project ID is required for Vertex AI. Set VERTE
- Google Cloud location is required for Vertex AI. Set VERTEX_
- MFA_VERIFICATION_FAILED
- MCP Provider requires active MCP session
- AUTHENTICATION_ERROR
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/273998f172046ae7.
Report an issue: GitHub.