eyaltoledano/claude-task-master · error · VertexApiError
API error (${statusCode}): ${errorMessage}
Error message
API error (${statusCode}): ${errorMessage} What it means
Any Vertex AI HTTP error status other than 401/403/400 (e.g. 404, 429, 500, 503) is wrapped in VertexApiError carrying the status code. This is the generic remote-API failure path in handleError. The status code is passed as a second argument and the Google message is embedded.
Source
Thrown at src/ai-providers/google-vertex.js:192
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
- Inspect the wrapped statusCode to branch handling: 429 → back off and retry; 5xx → retry later; 404 → fix model/region.
- For 429, add exponential backoff and check project quotas in the Google Cloud console.
- Check the Google Cloud status dashboard for outages if 5xx persists.
- For 404, verify endpoint URL components (project, location, publisher, model).
Example fix
// before: immediate failure on 429
// after: retry with backoff
// try { await client.generate(...) } catch (e) {
// if (e instanceof VertexApiError && e.statusCode === 429) return retryWithBackoff(fn, 5);
// throw e;
// } Defensive patterns
Strategy: retry
Type guard
function isVertexApiError(e) {
return e instanceof Error && /^API error \(\d+\):/.test(e.message);
}
function getStatusCode(e) {
const m = /^API error \((\d+)\):/.exec(e?.message || '');
return m ? Number(m[1]) : null;
} Try / catch
try {
return await call();
} catch (e) {
const code = getStatusCode(e);
if (code === 429 || code >= 500) return retryWithBackoff(call, { retries: 5, baseMs: 500 });
if (code === 404) console.error('Check model/region endpoint:', e.message);
throw e;
} Prevention
- Implement exponential backoff with jitter for 429/5xx
- Monitor project quotas in the Google Cloud console
- Subscribe to the Google Cloud status dashboard for outages
- Log statusCode from VertexApiError for alerting
When it happens
Trigger: getClient()/API call gets an HTTP error response whose status is not 401/403/400; handleError falls into the else branch.
Common situations: 429 rate limiting/quota exceeded, 5xx Google-side outages, 404 for nonexistent endpoints/models, region-wide capacity issues.
Related errors
- POLL_FAILED
- ${this.name} API error during ${operation}: ${errorMessage}
- Authentication failed: ${errorMessage}
- Invalid request: ${errorMessage}
- Vertex AI ${operation} failed: ${error.message}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/b7c21b9f35d05ce5.
Report an issue: GitHub.