ATH-MaaS/Pixelle-Video · error · HTTPException
str(e)
Error message
str(e)
What it means
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.
Source
Thrown at api/routers/tasks.py:49
limit: int = Query(100, ge=1, le=1000, description="Maximum number of tasks")
):
"""
List tasks
Retrieve list of tasks with optional filtering.
- **status**: Optional filter by status (pending/running/completed/failed/cancelled)
- **limit**: Maximum number of tasks to return (default 100)
Returns list of tasks sorted by creation time (newest first).
"""
try:
tasks = task_manager.list_tasks(status=status, limit=limit)
return tasks
except Exception as e:
logger.error(f"List tasks error: {e}")
raise HTTPException(status_code=500, detail=str(e))
@router.get("/{task_id}", response_model=Task)
async def get_task(task_id: str):
"""
Get task details
Retrieve detailed information about a specific task.
- **task_id**: Task ID
Returns task details including status, progress, and result (if completed).
"""
try:
task = task_manager.get_task(task_id)
if not task:
raise HTTPException(status_code=404, detail=f"Task {task_id} not found")View on GitHub (pinned to 848b054e4f)
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
Example fix
// before
except Exception as e:
logger.error(f"List tasks error: {e}")
raise HTTPException(status_code=500, detail=str(e))
// after
except Exception:
logger.exception("List tasks error")
raise HTTPException(status_code=500, detail="Unable to list tasks") Defensive patterns
Strategy: retry
Validate before calling
// validate query params before calling
const validStatus = ['pending','running','completed','failed','cancelled'];
if (status && !validStatus.includes(status)) throw new Error(`invalid status: ${status}`);
if (limit < 1 || limit > 1000) throw new Error('limit must be 1-1000'); Type guard
function isTaskList(r) { return Array.isArray(r) && r.every(t => typeof t.id === 'string' && typeof t.status === 'string'); } Try / catch
async function listTasks(params, attempts = 3) {
try {
const res = await fetch('/tasks?' + new URLSearchParams(params));
if (!res.ok) throw Object.assign(new Error('list tasks failed'), {status: res.status});
return await res.json();
} catch (err) {
if (err.status === 500 && attempts > 1) {
await sleep(500);
return listTasks(params, attempts - 1);
}
throw err;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/de4e2faf79b2fb4c.
Report an issue: GitHub.