eyaltoledano/claude-task-master · error · Error
API request failed: ${response.status} - ${errorText}
Error message
API request failed: ${response.status} - ${errorText} What it means
performExport() POSTs the task payload to the export API endpoint and checks response.ok. On any non-2xx response it reads the body and throws a plain Error of the form 'API request failed: <status> - <body>'. This surfaces server-side rejections (4xx/5xx) from the bulk-task export endpoint, including the raw response text for diagnosis.
Source
Thrown at packages/tm-core/src/modules/integration/services/export.service.ts:703
// Get auth token
const accessToken = await this.authManager.getAccessToken();
if (!accessToken) {
throw new Error('Not authenticated');
}
// Make API request
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
},
body: JSON.stringify(requestBody)
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`API request failed: ${response.status} - ${errorText}`
);
}
const result = (await response.json()) as BulkTasksResponse;
if (result.failedCount > 0) {
const failedTasks = result.results
.filter((r) => !r.success)
.map((r) => `${r.externalId}: ${r.error}`)
.join(', ');
console.warn(
`Warning: ${result.failedCount} tasks failed to import: ${failedTasks}`
);
}
console.log(
`Successfully exported ${result.successCount} of ${result.totalTasks} tasks to brief ${briefId}`View on GitHub (pinned to c0c98d367c)
Solutions
- Read the status and body in the error message — it contains the server's diagnostic text.
- For 401/403, re-authenticate (`tm auth login`) and confirm org/brief permissions.
- For 413/429, export in smaller batches or retry after backoff.
- For 5xx, retry with exponential backoff; if persistent, check the service status / API base domain configuration.
- For 404, verify TM_PUBLIC_BASE_DOMAIN points to the correct API environment.
Example fix
// before
await exportService.exportTasks(options); // throws on any 4xx/5xx
// after — wrap with retry for transient failures
try {
await exportService.exportTasks(options);
} catch (e) {
if (/API request failed: (5\d\d|429)/.test(e.message)) {
await retryWithBackoff(() => exportService.exportTasks(options));
} else throw e;
} Defensive patterns
Strategy: retry
Try / catch
async function exportWithRetry(options, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await exportService.exportTasks(options);
} catch (e) {
const m = /API request failed: (\d{3})/.exec(e.message);
const status = m ? Number(m[1]) : 0;
if (status === 429 || status >= 500) {
await new Promise(r => setTimeout(r, 2 ** attempt * 500));
continue;
}
if (status === 401 || status === 403) {
await tmCore.auth.login(); // refresh credentials, then retry once
continue;
}
throw e;
}
}
throw new Error('Export failed after retries');
} Prevention
- Re-authenticate before long-running exports so tokens don't expire mid-call
- Chunk very large task sets to avoid 413 payload-size rejections
- Verify TM_PUBLIC_BASE_DOMAIN points at the intended API environment
- Build exponential backoff around the export call for 429/5xx resilience
- Monitor the response body in error messages — it carries the server's diagnostic detail
When it happens
Trigger: The export HTTP call returns a non-OK status: 400 malformed payload, 401/403 expired or insufficient-permission token, 404 wrong API base URL/path, 409 conflict, 413 payload too large (very large task sets), 429 rate limit, or 5xx server error.
Common situations: Expired token mid-session (401); exporting thousands of tasks exceeding body-size limits (413); brief or org deleted server-side between validation and export (404); API outage or deploy in progress (502/503); misconfigured TM_PUBLIC_BASE_DOMAIN pointing at the wrong environment.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- EXPORT_FAILED
- API_ERROR
- NETWORK_ERROR
- Remote tag creation failed
- Warning: ${result.failedCount} tasks failed to import: ${fai
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/dc377c77ffe56998.
Report an issue: GitHub.