davila7/claude-code-templates · error
Task not found
Error message
Task not found
What it means
GET /api/task/:taskId looks up the task in the in-memory activeTasks Map and returns 404 when no task with that ID exists. Task IDs are only held in the server process's memory, so they disappear on restart and are never persisted.
Source
Thrown at cli-tool/src/sandbox-server.js:180
// Execute based on mode
if (mode === 'cloud') {
executeE2BTask(task);
} else {
executeLocalTask(task);
}
res.json({
success: true,
taskId: taskId,
message: 'Task started successfully'
});
});
// API endpoint to get task status
app.get('/api/task/:taskId', (req, res) => {
const task = activeTasks.get(req.params.taskId);
if (!task) {
return res.status(404).json({
success: false,
error: 'Task not found'
});
}
res.json({
success: true,
task: {
id: task.id,
title: task.title,
status: task.status,
progress: task.progress,
output: task.output.join('\\n'),
startTime: task.startTime,
endTime: task.endTime,
sandboxId: task.sandboxId
}
});View on GitHub (pinned to a0851ed10c)
Solutions
- Re-submit the task via POST /api/execute to get a fresh task ID
- Verify the task ID string exactly matches what /api/execute returned (task-<timestamp>-<random>)
- Keep the same server process alive while polling, or persist tasks externally if cross-restart status is needed
Defensive patterns
Strategy: fallback
Validate before calling
const taskRes = await fetch(`${base}/api/task/${encodeURIComponent(taskId)}`);
if (taskRes.status === 404) {
// task lost (server restart?) — resubmit
const redo = await fetch(`${base}/api/execute`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt }) });
const { taskId: newId } = await redo.json();
} Try / catch
try { const r = await fetch(url); if (r.status === 404) { /* resubmit */ } } catch (e) { /* network error: retry with backoff */ } Prevention
- Store the task ID returned by /api/execute exactly and urlencode it
- Don't restart the server while tasks are in flight
- Treat 404 on polling as a signal to resubmit, not a hard failure
When it happens
Trigger: Polling /api/task/<id> with a malformed or wrong ID (e.g. missing the task- prefix generated by /api/execute); polling after the server restarted; polling a task created by a different server instance (multiple sandbox servers on different ports).
Common situations: Client resumes polling after a server restart; typos in task ID; load-balanced or redeployed server losing in-memory state; very long-running tasks where the client reconnects later.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Conversation not found
- Not found
- Sandbox Interface Not Found - The sandbox-interface.html fil
- Components file not found
- File not found
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/1eb36edba537a25b.
Report an issue: GitHub.