{"record":{"id":"5d770aa641f260aa","repo":"calesthio/OpenMontage","slug":"tokenhub-task-task-id-did-not-finish-within-tim-5d770a","errorCode":null,"errorMessage":"TokenHub task {task_id} did not finish within {timeout_seconds}s","messagePattern":"TokenHub task (.+?) did not finish within (.+?)s","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"tools/video/hunyuan_cloud_video.py","lineNumber":490,"sourceCode":"                    raise RuntimeError(\n                        f\"TokenHub task {task_id} completed but no data.url: {data}\"\n                    )\n                return video_url\n\n            if status == \"failed\":\n                error_info = data.get(\"error\") or {}\n                error_msg = error_info.get(\"message\", \"unknown error\")\n                raise RuntimeError(\n                    f\"TokenHub task {task_id} failed: {error_msg}\"\n                )\n\n            # queued / running / in_progress — continue polling\n            if status not in (\"queued\", \"running\", \"in_progress\"):\n                raise RuntimeError(\n                    f\"TokenHub task {task_id} returned unknown status: {status}\"\n                )\n\n        raise TimeoutError(\n            f\"TokenHub task {task_id} did not finish within {timeout_seconds}s\"\n        )\n\n    # ------------------------------------------------------------------\n    # Error handling helpers\n    # ------------------------------------------------------------------\n\n    @staticmethod\n    def _safe_error(exc: Exception) -> str:\n        \"\"\"Redact secret values from exception messages.\"\"\"\n        msg = str(exc)\n        for var in (\"TENCENT_TOKENHUB_API_KEY\",):\n            val = os.environ.get(var, \"\")\n            if val:\n                msg = msg.replace(val, \"[redacted]\")\n        return msg\n\n    @staticmethod","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/hunyuan_cloud_video.py#L472-L508","documentation":"Raised when a TokenHub video task is still in a non-terminal state (queued/running/in_progress) when the caller-supplied timeout_seconds elapses. Unlike status='failed' (error 252), the job was healthy — just slow — and may still complete on the provider after this tool gives up.","triggerScenarios":"Long Hunyuan generations (high duration/resolution) where the poll loop runs past timeout_seconds; provider queues backed up at peak times; an aggressively small timeout configured by the caller.","commonSituations":"Default timeout tuned for short clips used on long renders; concurrent batch submissions exhausting provider capacity; regional TokenHub slowdowns; retry storms amplifying queue depth.","solutions":["Increase timeout_seconds on the tool call to match the expected render time for your duration/resolution.","Reduce requested duration or resolution so the task finishes sooner.","Space out batch submissions to avoid queue saturation.","Retry later — the task may have finished server-side even though this call timed out (beware duplicate billing)."],"exampleFix":"# before\n{\"operation\": \"text_to_video\", \"timeout_seconds\": 120}\n\n# after\n{\"operation\": \"text_to_video\", \"timeout_seconds\": 900}","handlingStrategy":"retry","validationCode":"expected_render_secs = 60 + 15 * inputs.get(\"duration\", 5)  # rough heuristic\ninputs[\"timeout_seconds\"] = max(inputs.get(\"timeout_seconds\", 0), int(expected_render_secs * 1.5))","typeGuard":null,"tryCatchPattern":"try:\n    result = hunyuan_cloud_video(inputs)\nexcept TimeoutError as e:\n    if \"did not finish within\" in str(e):\n        time.sleep(60)\n        result = hunyuan_cloud_video({**inputs, \"timeout_seconds\": inputs[\"timeout_seconds\"] * 2})\n    else:\n        raise","preventionTips":["Scale timeout_seconds with requested duration and resolution.","Throttle concurrent submissions so provider queues stay shallow.","Remember a timed-out task may still bill and complete server-side."],"tags":["hunyuan","tokenhub","timeout","polling","async-jobs"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}