{"record":{"id":"b7c21b9f35d05ce5","repo":"eyaltoledano/claude-task-master","slug":"api-error-statuscode-errormessage","errorCode":null,"errorMessage":"API error (${statusCode}): ${errorMessage}","messagePattern":"API error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"VertexApiError","httpStatus":null,"severity":"error","filePath":"src/ai-providers/google-vertex.js","lineNumber":192,"sourceCode":"\t\t\terror.name === 'VertexAuthError' ||\n\t\t\terror.name === 'VertexConfigError' ||\n\t\t\terror.name === 'VertexApiError'\n\t\t) {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Handle network/API errors\n\t\tif (error.response) {\n\t\t\tconst statusCode = error.response.status;\n\t\t\tconst errorMessage = error.response.data?.error?.message || error.message;\n\n\t\t\t// Categorize by status code\n\t\t\tif (statusCode === 401 || statusCode === 403) {\n\t\t\t\tthrow new VertexAuthError(`Authentication failed: ${errorMessage}`);\n\t\t\t} else if (statusCode === 400) {\n\t\t\t\tthrow new VertexConfigError(`Invalid request: ${errorMessage}`);\n\t\t\t} else {\n\t\t\t\tthrow new VertexApiError(\n\t\t\t\t\t`API error (${statusCode}): ${errorMessage}`,\n\t\t\t\t\tstatusCode\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Generic error handling\n\t\tthrow new Error(`Vertex AI ${operation} failed: ${error.message}`);\n\t}\n}\n","sourceCodeStart":174,"sourceCodeEnd":203,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/google-vertex.js#L174-L203","documentation":"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.","triggerScenarios":"getClient()/API call gets an HTTP error response whose status is not 401/403/400; handleError falls into the else branch.","commonSituations":"429 rate limiting/quota exceeded, 5xx Google-side outages, 404 for nonexistent endpoints/models, region-wide capacity issues.","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)."],"exampleFix":"// before: immediate failure on 429\n// after: retry with backoff\n// try { await client.generate(...) } catch (e) {\n//   if (e instanceof VertexApiError && e.statusCode === 429) return retryWithBackoff(fn, 5);\n//   throw e;\n// }","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isVertexApiError(e) {\n  return e instanceof Error && /^API error \\(\\d+\\):/.test(e.message);\n}\nfunction getStatusCode(e) {\n  const m = /^API error \\((\\d+)\\):/.exec(e?.message || '');\n  return m ? Number(m[1]) : null;\n}","tryCatchPattern":"try {\n  return await call();\n} catch (e) {\n  const code = getStatusCode(e);\n  if (code === 429 || code >= 500) return retryWithBackoff(call, { retries: 5, baseMs: 500 });\n  if (code === 404) console.error('Check model/region endpoint:', e.message);\n  throw e;\n}","preventionTips":["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"],"tags":["http-error","google-vertex","api-error","retryable"],"backgroundTag":"http-api-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}