ATH-MaaS/Pixelle-Video · error · Exception

Media generation failed: {error_msg}

Error message

Media generation failed: {error_msg}

What it means

MediaService.__call__ executes a ComfyUI/RunningHub workflow via ComfyKit's kit.execute() and expects result.status == 'completed'. When the workflow finishes with any other status, the service logs and re-raises result.msg (or 'Unknown error' if empty) wrapped as 'Media generation failed: ...'. It signals the remote workflow run itself failed, not a client-side bug.

Source

Thrown at pixelle_video/services/media.py:280

            kit = await self.core._get_or_create_comfykit()
            
            # Determine what to pass to ComfyKit based on source
            if workflow_info["source"] == "runninghub" and "workflow_id" in workflow_info:
                # RunningHub: pass workflow_id (ComfyKit will use runninghub backend)
                workflow_input = workflow_info["workflow_id"]
                logger.info(f"Executing RunningHub workflow: {workflow_input}")
            else:
                # Selfhost: pass file path (ComfyKit will use local ComfyUI)
                workflow_input = workflow_info["path"]
                logger.info(f"Executing selfhost workflow: {workflow_input}")
            
            result = await kit.execute(workflow_input, workflow_params)
            
            # 5. Handle result based on specified media_type
            if result.status != "completed":
                error_msg = result.msg or "Unknown error"
                logger.error(f"Media generation failed: {error_msg}")
                raise Exception(f"Media generation failed: {error_msg}")
            
            # Extract media based on specified type
            if media_type == "video":
                # Video workflow - get video from result
                if not result.videos:
                    logger.error("No video generated (workflow returned no videos)")
                    raise Exception("No video generated")
                
                video_url = result.videos[0]
                logger.info(f"✅ Generated video: {video_url}")
                
                # Try to extract duration from result (if available)
                duration = None
                if hasattr(result, 'duration') and result.duration:
                    duration = result.duration
                
                return MediaResult(
                    media_type="video",

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Read the {error_msg} suffix in the exception and the accompanying logger.error line — it carries result.msg from ComfyKit with the actual backend failure reason; fix that underlying cause first.
  2. Verify the workflow_id (RunningHub) or workflow file path (selfhost) exists and is the correct published version for the requested media_type.
  3. Validate workflow_params before calling: only pass parameters the workflow defines, with valid ranges (width/height divisible by 8, steps > 0, valid sampler name).
  4. Check backend health: for selfhost confirm ComfyUI is up and required custom nodes/models are installed; for RunningHub confirm API key validity and account quota/task limits.
  5. Retry the call if the message indicates a transient backend issue (timeout, queue busy, OOM), ideally with backoff.

Example fix

// before
result = await kit.execute(workflow_input, workflow_params)
if result.status != "completed":
    raise Exception(f"Media generation failed: {result.msg}")
// after
result = await kit.execute(workflow_input, workflow_params)
if result.status != "completed":
    logger.error(f"Workflow {workflow_input} failed: {result.msg}")
    raise WorkflowExecutionError(workflow_input, result.status, result.msg)  # typed error with context
Defensive patterns

Strategy: try-catch

Validate before calling

# before calling MediaService.__call__
assert media_type in ("video", "image"), f"invalid media_type: {media_type}"
assert prompt and prompt.strip(), "prompt must be non-empty"
if width is not None:
    assert width > 0 and width % 8 == 0, "width must be positive and divisible by 8"
if height is not None:
    assert height > 0 and height % 8 == 0, "height must be positive and divisible by 8"
if steps is not None:
    assert 1 <= steps <= 150, "steps out of range"
# confirm backend/config reachable
# selfhost: httpx.get(f"{comfyui_url}/system_stats").raise_for_status()
# runninghub: verify RUNNINGHUB_API_KEY is set and workflow_id is valid

Type guard

def workflow_completed(result) -> bool:
    return getattr(result, "status", None) == "completed" and bool(getattr(result, "msg", None)) is not True  # completed implies no failure msg

Try / catch

try:
    media = await media_service(...)
except Exception as e:
    if str(e).startswith("Media generation failed:"):
        reason = str(e).removeprefix("Media generation failed: ")
        logger.warning("workflow failed: %s", reason)
        media = await media_service(...)  # retry once or fall back to alternate workflow
    else:
        raise

Prevention

When it happens

Trigger: Calling MediaService.__call__ (media_type 'video' or 'image') where kit.execute(workflow_input, workflow_params) returns a result whose status is not 'completed' — e.g. RunningHub workflow API reports failure/timeout, workflow node errors, invalid workflow_id, invalid parameter values (bad seed, out-of-range width/height/steps), or ComfyUI node exceptions surfaced in result.msg.

Common situations: Expired or wrong RunningHub API key; referencing a deleted/renamed RunningHub workflow_id; selfhost ComfyUI missing custom nodes or models required by the workflow JSON; passing params that the workflow doesn't accept or with invalid values; GPU OOM or queue timeout on the backend.

Related errors


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