{"record":{"id":"8770d442a2376e91","repo":"ATH-MaaS/Pixelle-Video","slug":"str-e-8770d4","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/video.py","lineNumber":175,"sourceCode":"        \n        # Call video generator service\n        result = await pixelle_video.generate_video(**video_params)\n        \n        # Get file size\n        file_size = os.path.getsize(result.video_path) if os.path.exists(result.video_path) else 0\n        \n        # Convert path to URL\n        video_url = path_to_url(request, result.video_path)\n        \n        return VideoGenerateResponse(\n            video_url=video_url,\n            duration=result.duration,\n            file_size=file_size\n        )\n        \n    except Exception as e:\n        logger.error(f\"Sync video generation error: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.post(\"/generate/async\", response_model=VideoGenerateAsyncResponse)\nasync def generate_video_async(\n    request_body: VideoGenerateRequest,\n    pixelle_video: PixelleVideoDep,\n    request: Request\n):\n    \"\"\"\n    Generate video asynchronously\n    \n    Creates a background task for video generation.\n    Returns immediately with a task_id for tracking progress.\n    \n    **Workflow:**\n    1. Submit video generation request\n    2. Receive task_id in response\n    3. Poll `/api/tasks/{task_id}` to check status","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/api/routers/video.py#L157-L193","documentation":"This is the generic catch-all at the end of generate_video_sync (api/routers/video.py:173-175): any Exception during sync video generation is logged and re-raised as HTTP 500 with detail=str(e). The message you see is whatever the underlying failure produced — missing frame_template, template resolution errors, ComfyUI/TTS/image workflow failures, or file system errors.","triggerScenarios":"Any unhandled exception inside POST /api/video/generate/sync — e.g. the frame_template ValueError, resolve_template_path not finding the template, generate_video failing (workflow errors, model unavailable), or os.path.getsize on a missing file — surfaces as HTTPException(500, detail=str(e)).","commonSituations":"Template name typo or template not deployed on the server; ComfyUI backend down or workflow missing; TTS/ref_audio path invalid; long-running generation exceeding client/proxy timeout (docs recommend /generate/async for videos > 30s); transient model load failures.","solutions":["Read the 'detail' field of the 500 response and the server log line 'Sync video generation error: {e}' to identify the underlying cause","If the detail is the frame_template message, add a valid frame_template to the request (see error 25)","If the detail mentions the template file, verify resolve_template_path can resolve it (template exists in the configured templates directory)","For timeouts or long videos, switch to POST /api/video/generate/async and poll /api/tasks/{task_id}","Check that the ComfyUI backend and required workflows/models are running and configured"],"exampleFix":"// before (client treats 500 as opaque)\nif (res.status === 500) throw new Error('generation failed');\n// after\nif (res.status === 500) {\n  const body = await res.json();\n  throw new Error('Video generation failed: ' + body.detail);\n}","handlingStrategy":"try-catch","validationCode":"payload = {\"text\": text, \"frame_template\": \"default\", \"mode\": mode}\nassert payload.get(\"frame_template\"), \"frame_template required\"\nif len(payload[\"text\"]) < 1:\n    raise ValueError(\"text is required\")","typeGuard":"def is_valid_generate_request(body: dict) -> bool:\n    return isinstance(body.get(\"text\"), str) and body[\"text\"] and \\\n           isinstance(body.get(\"frame_template\"), str) and bool(body[\"frame_template\"])","tryCatchPattern":"try:\n    resp = requests.post(f\"{BASE}/api/video/generate/sync\", json=payload, timeout=600)\n    resp.raise_for_status()\n    return resp.json()\nexcept requests.Timeout:\n    logger.warning(\"Sync generation timed out; fall back to async endpoint\")\n    return submit_async_and_poll(payload)\nexcept requests.HTTPError as e:\n    logger.error(\"Video generation failed: %s\", e.response.json().get(\"detail\"))\n    raise","preventionTips":["Use /generate/async for videos expected to exceed ~30s to avoid timeouts","Log the response 'detail' field — it mirrors the server-side exception message","Check ComfyUI backend health and workflow availability before bulk generation","Validate frame_template and text non-empty before calling the sync endpoint"],"tags":["fastapi","http-500","error-handling","video"],"backgroundTag":"unhandled-exception-500","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}