{"record":{"id":"092c9d94b9b99989","repo":"ATH-MaaS/Pixelle-Video","slug":"task-task-id-not-found","errorCode":null,"errorMessage":"Task {task_id} not found","messagePattern":"Task (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"api/routers/tasks.py","lineNumber":67,"sourceCode":"        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\"/{task_id}\", response_model=Task)\nasync def get_task(task_id: str):\n    \"\"\"\n    Get task details\n    \n    Retrieve detailed information about a specific task.\n    \n    - **task_id**: Task ID\n    \n    Returns task details including status, progress, and result (if completed).\n    \"\"\"\n    try:\n        task = task_manager.get_task(task_id)\n        \n        if not task:\n            raise HTTPException(status_code=404, detail=f\"Task {task_id} not found\")\n        \n        return task\n        \n    except HTTPException:\n        raise\n    except Exception as e:\n        logger.error(f\"Get task error: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.delete(\"/{task_id}\")\nasync def cancel_task(task_id: str):\n    \"\"\"\n    Cancel task\n    \n    Cancel a running or pending task.\n    \n    - **task_id**: Task ID","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/api/routers/tasks.py#L49-L85","documentation":"A 404 HTTPException raised by the GET /tasks/{task_id} endpoint in api/routers/tasks.py when task_manager.get_task(task_id) returns None/falsy. It is the API's explicit signal that no task exists with the supplied ID. This is an expected, controlled response, not an internal failure.","triggerScenarios":"Calling GET /{task_id} with a task_id that was never created, a typo'd or truncated UUID, or a task whose record was purged from the manager's store (e.g. in-memory TaskManager restarted, or task evicted after retention/cleanup).","commonSituations":"Client stores the task ID from a 202-style submit response but the server restarted (in-memory task registry lost); polling a task after it aged out of retention; hardcoding example IDs from docs; load balancer routing the poll to a different backend instance than the one that owns the task.","solutions":["Verify the task_id used in the request matches the ID returned by the task-creation endpoint exactly (no truncation, no whitespace).","Re-create the task if the server was restarted and it used an in-memory task manager; persist task IDs externally if tasks must survive restarts.","Confirm you are polling the same server instance that accepted the task (check sticky sessions or shared task store).","Check whether the task was cancelled/completed and cleaned up by retention logic before polling.","Handle HTTP 404 in the client by treating the task as unknown and stopping polling instead of retrying forever."],"exampleFix":"// before: poll blindly\nconst res = await fetch(`/tasks/${taskId}`);\nconst task = await res.json();\n// after: check status first\nconst res = await fetch(`/tasks/${taskId}`);\nif (res.status === 404) {\n  throw new Error(`Task ${taskId} no longer exists; re-submit the job`);\n}\nconst task = await res.json();","handlingStrategy":"try-catch","validationCode":"// client-side pre-check\nif (!taskId || !/^[0-9a-fA-F-]{8,64}$/.test(taskId.trim())) {\n  throw new Error('Refusing to poll: task_id missing or malformed');\n}","typeGuard":"function isTaskResponse(x) {\n  return x != null && typeof x === 'object' && 'task_id' in x && 'status' in x;\n}","tryCatchPattern":"try {\n  const res = await fetch(`/tasks/${taskId}`);\n  if (res.status === 404) {\n    // task gone / server restarted: stop polling, re-submit if needed\n    return null;\n  }\n  if (!res.ok) throw new Error(`Unexpected ${res.status}`);\n  return await res.json();\n} catch (err) {\n  handlePollFailure(err);\n}","preventionTips":["Persist the task ID returned at creation; never hardcode or hand-type IDs.","Stop polling after a 404 instead of retrying indefinitely.","Back task storage with a shared/persistent store so restarts don't orphan task IDs.","Trim/validate the ID before sending; watch for copy-paste whitespace."],"tags":["http-404","rest-api","task-management","fastapi"],"backgroundTag":"resource-not-found-404","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}