ATH-MaaS/Pixelle-Video · error · HTTPException

str(e)

Error message

str(e)

What it means

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.

Source

Thrown at api/routers/video.py:175

        
        # Call video generator service
        result = await pixelle_video.generate_video(**video_params)
        
        # Get file size
        file_size = os.path.getsize(result.video_path) if os.path.exists(result.video_path) else 0
        
        # Convert path to URL
        video_url = path_to_url(request, result.video_path)
        
        return VideoGenerateResponse(
            video_url=video_url,
            duration=result.duration,
            file_size=file_size
        )
        
    except Exception as e:
        logger.error(f"Sync video generation error: {e}")
        raise HTTPException(status_code=500, detail=str(e))


@router.post("/generate/async", response_model=VideoGenerateAsyncResponse)
async def generate_video_async(
    request_body: VideoGenerateRequest,
    pixelle_video: PixelleVideoDep,
    request: Request
):
    """
    Generate video asynchronously
    
    Creates a background task for video generation.
    Returns immediately with a task_id for tracking progress.
    
    **Workflow:**
    1. Submit video generation request
    2. Receive task_id in response
    3. Poll `/api/tasks/{task_id}` to check status

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Read the 'detail' field of the 500 response and the server log line 'Sync video generation error: {e}' to identify the underlying cause
  2. If the detail is the frame_template message, add a valid frame_template to the request (see error 25)
  3. If the detail mentions the template file, verify resolve_template_path can resolve it (template exists in the configured templates directory)
  4. For timeouts or long videos, switch to POST /api/video/generate/async and poll /api/tasks/{task_id}
  5. Check that the ComfyUI backend and required workflows/models are running and configured

Example fix

// before (client treats 500 as opaque)
if (res.status === 500) throw new Error('generation failed');
// after
if (res.status === 500) {
  const body = await res.json();
  throw new Error('Video generation failed: ' + body.detail);
}
Defensive patterns

Strategy: try-catch

Validate before calling

payload = {"text": text, "frame_template": "default", "mode": mode}
assert payload.get("frame_template"), "frame_template required"
if len(payload["text"]) < 1:
    raise ValueError("text is required")

Type guard

def is_valid_generate_request(body: dict) -> bool:
    return isinstance(body.get("text"), str) and body["text"] and \
           isinstance(body.get("frame_template"), str) and bool(body["frame_template"])

Try / catch

try:
    resp = requests.post(f"{BASE}/api/video/generate/sync", json=payload, timeout=600)
    resp.raise_for_status()
    return resp.json()
except requests.Timeout:
    logger.warning("Sync generation timed out; fall back to async endpoint")
    return submit_async_and_poll(payload)
except requests.HTTPError as e:
    logger.error("Video generation failed: %s", e.response.json().get("detail"))
    raise

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/8770d442a2376e91. Report an issue: GitHub.