{"record":{"id":"626f8e39b9112c24","repo":"calesthio/OpenMontage","slug":"tokenhub-task-task-id-returned-unknown-status-626f8e","errorCode":null,"errorMessage":"TokenHub task {task_id} returned unknown status: {status}","messagePattern":"TokenHub task (.+?) returned unknown status: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/video/hunyuan_cloud_video.py","lineNumber":486,"sourceCode":"            if status == \"completed\":\n                result_data = data.get(\"data\") or {}\n                video_url = result_data.get(\"url\")\n                if not video_url:\n                    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:","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/hunyuan_cloud_video.py#L468-L504","documentation":"Raised when the TokenHub poll returns a status string outside the recognized set {completed, failed, queued, running, in_progress}. The tool treats unknown states as errors rather than waiting indefinitely on a state it cannot interpret — this protects against both typos in the state machine and new provider states (e.g. 'cancelled', 'partial') appearing after an API update.","triggerScenarios":"Poll response JSON has data.status set to something like 'cancelled', 'expired', 'success', or 'PROCESSING' (different casing/wording introduced by the provider). The whitelist check fires immediately.","commonSituations":"TokenHub adds a new lifecycle state in an API revision; case or wording differences between endpoints; tasks cancelled server-side (e.g. by moderation) landing in an unmodelled state.","solutions":["Read the {status} value in the error and map it to its meaning in current TokenHub docs (e.g. 'cancelled' = aborted server-side, no retry value).","If the new state is a valid in-flight state, update the whitelist in hunyuan_cloud_video's poll loop or update OpenMontage where the fix landed.","Resubmit the task if the state is equivalent to a terminal abort.","Report the new status string upstream so the state machine gets extended."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = hunyuan_cloud_video(inputs)\nexcept RuntimeError as e:\n    if \"unknown status\" in str(e):\n        status = str(e).rsplit(\":\", 1)[-1].strip()\n        if status.lower() in (\"cancelled\", \"canceled\", \"expired\"):\n            raise TaskAborted(status) from e  # terminal, do not retry\n        raise ProviderContractError(f\"new TokenHub status: {status}\") from e\n    raise","preventionTips":["Map unrecognized states explicitly instead of retrying them.","Track TokenHub release notes for new lifecycle states and update whitelists."],"tags":["hunyuan","tokenhub","api-contract","state-machine","polling"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}