harry0703/MoneyPrinterTurbo · error · HttpException

{request_id}: task not found

Error message

{request_id}: task not found

What it means

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).

Source

Thrown at app/controllers/v1/video.py:270

    endpoint = config.app.get("endpoint", "").rstrip("/")
    task = sm.state.get_task(task_id)
    if task:
        task_dir = utils.task_dir()
        response_task = _public_task_data(task)

        if "videos" in task:
            response_task["videos"] = [
                _task_file_to_uri(v, endpoint, task_dir, request_id)
                for v in task["videos"]
            ]
        if "combined_videos" in task:
            response_task["combined_videos"] = [
                _task_file_to_uri(v, endpoint, task_dir, request_id)
                for v in task["combined_videos"]
            ]
        return utils.get_response(200, response_task)

    raise HttpException(
        task_id=task_id, status_code=404, message=f"{request_id}: task not found"
    )


@router.delete(
    "/tasks/{task_id}",
    response_model=TaskDeletionResponse,
    summary="Delete a generated short video task",
)
def delete_video(request: Request, task_id: str = Path(..., description="Task ID")):
    request_id = base.get_task_id(request)
    task = sm.state.get_task(task_id)
    if task:
        if tm.is_task_busy(task):
            logger.warning(
                f"refuse to delete busy task, request_id: {request_id}, "
                f"task_id: {task_id}, state: {task.get('state')}, "
                f"cross_post_state: {task.get('cross_post_state')}"

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. If the server restarted (in-memory manager), accept that old task IDs are gone and resubmit work as needed.
  2. Verify the ID character-for-character against the create response; re-list tasks via GET /api/v1/tasks to confirm what exists.
  3. Stop polling after 404 instead of retrying — it will not come back on its own.

Example fix

# before
while True:
    task = requests.get(f"{base}/api/v1/tasks/{task_id}", headers=h).json()

# after
resp = requests.get(f"{base}/api/v1/tasks/{task_id}", headers=h)
if resp.status_code == 404:
    logging.warning("task %s gone (deleted or server restarted)", task_id)
    break
task = resp.json()
Defensive patterns

Strategy: try-catch

Try / catch

resp = requests.get(f"{base}/api/v1/tasks/{task_id}", headers=h)
if resp.status_code == 404:
    log.warning("task %s not found (deleted or server restarted); stop polling", task_id)
    return None
task = resp.json()

Prevention

When it happens

Trigger: 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}.

Common situations: 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.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/c57924b1ef1baf42. Report an issue: GitHub.