{"record":{"id":"c57924b1ef1baf42","repo":"harry0703/MoneyPrinterTurbo","slug":"request-id-task-not-found","errorCode":null,"errorMessage":"{request_id}: task not found","messagePattern":"(.+?): task not found","errorType":"http","errorClass":"HttpException","httpStatus":404,"severity":"error","filePath":"app/controllers/v1/video.py","lineNumber":270,"sourceCode":"    endpoint = config.app.get(\"endpoint\", \"\").rstrip(\"/\")\n    task = sm.state.get_task(task_id)\n    if task:\n        task_dir = utils.task_dir()\n        response_task = _public_task_data(task)\n\n        if \"videos\" in task:\n            response_task[\"videos\"] = [\n                _task_file_to_uri(v, endpoint, task_dir, request_id)\n                for v in task[\"videos\"]\n            ]\n        if \"combined_videos\" in task:\n            response_task[\"combined_videos\"] = [\n                _task_file_to_uri(v, endpoint, task_dir, request_id)\n                for v in task[\"combined_videos\"]\n            ]\n        return utils.get_response(200, response_task)\n\n    raise HttpException(\n        task_id=task_id, status_code=404, message=f\"{request_id}: task not found\"\n    )\n\n\n@router.delete(\n    \"/tasks/{task_id}\",\n    response_model=TaskDeletionResponse,\n    summary=\"Delete a generated short video task\",\n)\ndef delete_video(request: Request, task_id: str = Path(..., description=\"Task ID\")):\n    request_id = base.get_task_id(request)\n    task = sm.state.get_task(task_id)\n    if task:\n        if tm.is_task_busy(task):\n            logger.warning(\n                f\"refuse to delete busy task, request_id: {request_id}, \"\n                f\"task_id: {task_id}, state: {task.get('state')}, \"\n                f\"cross_post_state: {task.get('cross_post_state')}\"","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/controllers/v1/video.py#L252-L288","documentation":"Returned by GET /api/v1/tasks/{task_id} in app/controllers/v1/video.py when sm.state.get_task(task_id) finds no task record. The 404 means the ID was never created, was deleted, or belongs to a different process lifetime (in-memory state lost on restart).","triggerScenarios":"Polling a task ID returned by a previous deployment after the service restarted (InMemoryTaskManager state is volatile); querying a typo'd or truncated ID; polling a task that another client deleted via DELETE /tasks/{id}.","commonSituations":"Server restart wiping in-memory task state while clients hold old IDs; copy/paste truncation of long IDs; race where one workflow deletes a task while another polls it.","solutions":["If the server restarted (in-memory manager), accept that old task IDs are gone and resubmit work as needed.","Verify the ID character-for-character against the create response; re-list tasks via GET /api/v1/tasks to confirm what exists.","Stop polling after 404 instead of retrying — it will not come back on its own."],"exampleFix":"# before\nwhile True:\n    task = requests.get(f\"{base}/api/v1/tasks/{task_id}\", headers=h).json()\n\n# after\nresp = requests.get(f\"{base}/api/v1/tasks/{task_id}\", headers=h)\nif resp.status_code == 404:\n    logging.warning(\"task %s gone (deleted or server restarted)\", task_id)\n    break\ntask = resp.json()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp = requests.get(f\"{base}/api/v1/tasks/{task_id}\", headers=h)\nif resp.status_code == 404:\n    log.warning(\"task %s not found (deleted or server restarted); stop polling\", task_id)\n    return None\ntask = resp.json()","preventionTips":["Persist nothing critical against in-memory task IDs across server restarts.","Verify IDs against GET /api/v1/tasks listings before deep-linking them.","Stop polling on 404 — the record will not reappear."],"tags":["http-404","task-lifecycle","polling","in-memory-state"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}