eyaltoledano/claude-task-master · error · VertexAuthError
Authentication failed: ${errorMessage}
Error message
Authentication failed: ${errorMessage} What it means
GoogleVertexProvider wraps HTTP errors from the Vertex AI REST endpoint in a VertexAuthError when the API responds with 401 or 403. This means the request reached Google but the credentials presented were rejected or lack permission. The original Google error message is preserved in the new error's message.
Source
Thrown at src/ai-providers/google-vertex.js:188
log('error', `Vertex AI ${operation} error:`, error);
// Handle known error types
if (
error.name === 'VertexAuthError' ||
error.name === 'VertexConfigError' ||
error.name === 'VertexApiError'
) {
throw error;
}
// Handle network/API errors
if (error.response) {
const statusCode = error.response.status;
const errorMessage = error.response.data?.error?.message || error.message;
// Categorize by status code
if (statusCode === 401 || statusCode === 403) {
throw new VertexAuthError(`Authentication failed: ${errorMessage}`);
} else if (statusCode === 400) {
throw new VertexConfigError(`Invalid request: ${errorMessage}`);
} else {
throw new VertexApiError(
`API error (${statusCode}): ${errorMessage}`,
statusCode
);
}
}
// Generic error handling
throw new Error(`Vertex AI ${operation} failed: ${error.message}`);
}
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Re-authenticate: run 'gcloud auth application-default login' or refresh the service-account key and set GOOGLE_APPLICATION_CREDENTIALS to it.
- Verify the service account has roles/aiplatform.user on the project and that the Vertex AI API is enabled (gcloud services enable aiplatform.googleapis.com).
- Confirm GOOGLE_VERTEX_PROJECT and GOOGLE_VERTEX_LOCATION match the project where credentials are valid.
- Read the embedded errorMessage in the thrown VertexAuthError for Google's exact denial reason (e.g. 'API not enabled' vs 'Permission denied').
Example fix
// before: stale/absent credentials
// vertex = new GoogleVertexProvider({ projectId: 'my-proj' }); // 401
// after
// gcloud auth application-default login
// export GOOGLE_APPLICATION_CREDENTIALS=/path/to/fresh-key.json Defensive patterns
Strategy: try-catch
Validate before calling
import { execSync } from 'child_process';
function hasGoogleCredentials() {
if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
return fs.existsSync(process.env.GOOGLE_APPLICATION_CREDENTIALS);
}
try { execSync('gcloud auth application-default print-access-token', { stdio: 'ignore' }); return true; }
catch { return false; }
}
if (!hasGoogleCredentials()) throw new Error('Set GOOGLE_APPLICATION_CREDENTIALS or run gcloud auth application-default login'); Type guard
function isVertexAuthError(e) {
return e instanceof Error && (e.name === 'VertexAuthError' || /Authentication failed:/.test(e.message));
} Try / catch
try {
await vertex.getClient(...);
} catch (e) {
if (/Authentication failed:/.test(e.message)) {
// refresh gcloud credentials / service-account key, then retry once
execSync('gcloud auth application-default login');
return await vertex.getClient(...);
}
throw e;
} Prevention
- Run gcloud auth application-default login and refresh tokens before long sessions
- Verify GOOGLE_APPLICATION_CREDENTIALS points to an existing, unrevoked key file
- Grant roles/aiplatform.user to the service account
- Enable the Vertex AI API in your project
When it happens
Trigger: getClient() calls the Vertex AI API and error.response.status is 401 or 403; handleError is invoked by the catch block around the request.
Common situations: Expired or missing Google Cloud auth token (e.g. not run 'gcloud auth application-default login'), GOOGLE_APPLICATION_CREDENTIALS pointing to a stale/revoked service-account key, service account lacking the 'Vertex AI User' (roles/aiplatform.user) IAM role, wrong project ID, or Vertex AI API not enabled for the project.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- MFA_VERIFICATION_FAILED
- MCP Provider requires active MCP session
- AUTHENTICATION_ERROR
- FLOW_NOT_FOUND
- OAUTH_FAILED
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/181d29f7743da222.
Report an issue: GitHub.