{"record":{"id":"8fa5acae6964d2c6","repo":"calesthio/OpenMontage","slug":"tokenhub-task-task-id-returned-unknown-status","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/graphics/hunyuan_image.py","lineNumber":517,"sourceCode":"            if status == \"completed\":\n                result_data = data.get(\"data\") or []\n                urls = [item.get(\"url\") for item in result_data if item.get(\"url\")]\n                if not urls:\n                    raise RuntimeError(\n                        f\"TokenHub task {task_id} completed but no data[].url: {data}\"\n                    )\n                return urls\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":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/graphics/hunyuan_image.py#L499-L535","documentation":"RuntimeError raised when the polled TokenHub task reports a status outside the known set {completed, failed, queued, running, in_progress}. This is a defensive guard: an unrecognized status string means the client cannot decide whether to keep polling, so it fails fast instead of spinning until timeout.","triggerScenarios":"TokenHub introduces a new intermediate status (e.g. 'pending', 'processing') or renames an existing one; a regional variant of the API returns locale-specific status strings; unexpected payload shapes from a proxy or gateway in front of the API.","commonSituations":"API version bump adding a new lifecycle state; custom middleware that rewrites response bodies; testing against a mock server with incorrect status values.","solutions":["Log the raw status string (included in the message) and check current TokenHub docs for the status lifecycle","If the new status is genuinely non-terminal, add it to the continue-polling tuple in _poll_task","Ensure requests hit the real TokenHub host, not an intermediate proxy that mutates responses","Pin or upgrade the tool version that matches the TokenHub API contract you target"],"exampleFix":"# before\nif status not in (\"queued\", \"running\", \"in_progress\"):\n    raise RuntimeError(...)\n# after (example: upstream added 'pending')\nif status not in (\"queued\", \"running\", \"in_progress\", \"pending\"):\n    raise RuntimeError(...)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    urls = client._poll_task(task_id, ...)\nexcept RuntimeError as e:\n    if \"unknown status\" in str(e):\n        # log the status and consult TokenHub lifecycle docs before patching","preventionTips":["Track TokenHub release notes for new statuses","Do not hit the API through body-rewriting proxies","Keep mocks aligned with real status strings in tests"],"tags":["hunyuan","tokenhub","schema","defensive-check"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}