{"record":{"id":"de4e2faf79b2fb4c","repo":"ATH-MaaS/Pixelle-Video","slug":"str-e-de4e2f","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/tasks.py","lineNumber":49,"sourceCode":"    limit: int = Query(100, ge=1, le=1000, description=\"Maximum number of tasks\")\n):\n    \"\"\"\n    List tasks\n    \n    Retrieve list of tasks with optional filtering.\n    \n    - **status**: Optional filter by status (pending/running/completed/failed/cancelled)\n    - **limit**: Maximum number of tasks to return (default 100)\n    \n    Returns list of tasks sorted by creation time (newest first).\n    \"\"\"\n    try:\n        tasks = task_manager.list_tasks(status=status, limit=limit)\n        return tasks\n        \n    except Exception as e:\n        logger.error(f\"List tasks error: {e}\")\n        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\")","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/api/routers/tasks.py#L31-L67","documentation":"GET /tasks converts any exception from task_manager.list_tasks() into HTTP 500 with str(e) as detail. The task listing/registry itself failed — for example corrupted in-memory task state, an invalid status filter path, or an internal error in the task manager — after query validation already passed.","triggerScenarios":"GET /tasks?status=...&limit=... when task_manager.list_tasks throws: internal state error, unexpected exception while sorting/filtering stored tasks, or serialization of a malformed Task record.","commonSituations":"Task manager registry in a bad state after a restart or memory pressure; a stored Task record missing required fields failing response serialization; bug in a new task-manager version.","solutions":["Check server logs for 'List tasks error:' to find the root cause","Retry the request — transient state issues may resolve","Call without the status/limit filters to isolate whether filtering triggers the failure","Restart the service if the in-memory task registry is corrupted","Server-side: return a sanitized message and log the full stack trace"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"List tasks error: {e}\")\n    raise HTTPException(status_code=500, detail=str(e))\n// after\nexcept Exception:\n    logger.exception(\"List tasks error\")\n    raise HTTPException(status_code=500, detail=\"Unable to list tasks\")","handlingStrategy":"retry","validationCode":"// validate query params before calling\nconst validStatus = ['pending','running','completed','failed','cancelled'];\nif (status && !validStatus.includes(status)) throw new Error(`invalid status: ${status}`);\nif (limit < 1 || limit > 1000) throw new Error('limit must be 1-1000');","typeGuard":"function isTaskList(r) { return Array.isArray(r) && r.every(t => typeof t.id === 'string' && typeof t.status === 'string'); }","tryCatchPattern":"async function listTasks(params, attempts = 3) {\n  try {\n    const res = await fetch('/tasks?' + new URLSearchParams(params));\n    if (!res.ok) throw Object.assign(new Error('list tasks failed'), {status: res.status});\n    return await res.json();\n  } catch (err) {\n    if (err.status === 500 && attempts > 1) {\n      await sleep(500);\n      return listTasks(params, attempts - 1);\n    }\n    throw err;\n  }\n}","preventionTips":["Retry transient 500s with backoff before surfacing to the user","Isolate failures by dropping the status/limit filters when debugging","Restart the service if the in-memory task registry appears corrupted","Keep task-manager versions in sync with the API to avoid serialization mismatches"],"tags":["http-500","task-manager","fastapi","state"],"backgroundTag":"internal-server-error-500","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}