{"record":{"id":"f1eb889dfe86aa32","repo":"ATH-MaaS/Pixelle-Video","slug":"media-generation-failed-error-msg","errorCode":null,"errorMessage":"Media generation failed: {error_msg}","messagePattern":"Media generation failed: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/media.py","lineNumber":280,"sourceCode":"            kit = await self.core._get_or_create_comfykit()\n            \n            # Determine what to pass to ComfyKit based on source\n            if workflow_info[\"source\"] == \"runninghub\" and \"workflow_id\" in workflow_info:\n                # RunningHub: pass workflow_id (ComfyKit will use runninghub backend)\n                workflow_input = workflow_info[\"workflow_id\"]\n                logger.info(f\"Executing RunningHub workflow: {workflow_input}\")\n            else:\n                # Selfhost: pass file path (ComfyKit will use local ComfyUI)\n                workflow_input = workflow_info[\"path\"]\n                logger.info(f\"Executing selfhost workflow: {workflow_input}\")\n            \n            result = await kit.execute(workflow_input, workflow_params)\n            \n            # 5. Handle result based on specified media_type\n            if result.status != \"completed\":\n                error_msg = result.msg or \"Unknown error\"\n                logger.error(f\"Media generation failed: {error_msg}\")\n                raise Exception(f\"Media generation failed: {error_msg}\")\n            \n            # Extract media based on specified type\n            if media_type == \"video\":\n                # Video workflow - get video from result\n                if not result.videos:\n                    logger.error(\"No video generated (workflow returned no videos)\")\n                    raise Exception(\"No video generated\")\n                \n                video_url = result.videos[0]\n                logger.info(f\"✅ Generated video: {video_url}\")\n                \n                # Try to extract duration from result (if available)\n                duration = None\n                if hasattr(result, 'duration') and result.duration:\n                    duration = result.duration\n                \n                return MediaResult(\n                    media_type=\"video\",","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/media.py#L262-L298","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Verify the workflow_id (RunningHub) or workflow file path (selfhost) exists and is the correct published version for the requested media_type.","Validate workflow_params before calling: only pass parameters the workflow defines, with valid ranges (width/height divisible by 8, steps > 0, valid sampler name).","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.","Retry the call if the message indicates a transient backend issue (timeout, queue busy, OOM), ideally with backoff."],"exampleFix":"// before\nresult = await kit.execute(workflow_input, workflow_params)\nif result.status != \"completed\":\n    raise Exception(f\"Media generation failed: {result.msg}\")\n// after\nresult = await kit.execute(workflow_input, workflow_params)\nif result.status != \"completed\":\n    logger.error(f\"Workflow {workflow_input} failed: {result.msg}\")\n    raise WorkflowExecutionError(workflow_input, result.status, result.msg)  # typed error with context","handlingStrategy":"try-catch","validationCode":"# before calling MediaService.__call__\nassert media_type in (\"video\", \"image\"), f\"invalid media_type: {media_type}\"\nassert prompt and prompt.strip(), \"prompt must be non-empty\"\nif width is not None:\n    assert width > 0 and width % 8 == 0, \"width must be positive and divisible by 8\"\nif height is not None:\n    assert height > 0 and height % 8 == 0, \"height must be positive and divisible by 8\"\nif steps is not None:\n    assert 1 <= steps <= 150, \"steps out of range\"\n# confirm backend/config reachable\n# selfhost: httpx.get(f\"{comfyui_url}/system_stats\").raise_for_status()\n# runninghub: verify RUNNINGHUB_API_KEY is set and workflow_id is valid","typeGuard":"def workflow_completed(result) -> bool:\n    return getattr(result, \"status\", None) == \"completed\" and bool(getattr(result, \"msg\", None)) is not True  # completed implies no failure msg","tryCatchPattern":"try:\n    media = await media_service(...)\nexcept Exception as e:\n    if str(e).startswith(\"Media generation failed:\"):\n        reason = str(e).removeprefix(\"Media generation failed: \")\n        logger.warning(\"workflow failed: %s\", reason)\n        media = await media_service(...)  # retry once or fall back to alternate workflow\n    else:\n        raise","preventionTips":["Pin and health-check the ComfyUI/RunningHub backend before submitting jobs.","Validate all workflow params against the workflow's declared input schema before execute.","Keep workflow_id/workflow file paths in config and verify them at startup.","Log result.msg verbatim; it contains the actionable backend failure reason.","Add idempotent retry with backoff for transient backend statuses."],"tags":["workflow-execution","comfyui","runninghub","media-generation","async"],"backgroundTag":"workflow-execution-failed","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}