calesthio/OpenMontage · error · RuntimeError

TokenHub task {task_id} returned unknown status: {status}

Error message

TokenHub task {task_id} returned unknown status: {status}

What it means

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.

Source

Thrown at tools/graphics/hunyuan_image.py:517

            if status == "completed":
                result_data = data.get("data") or []
                urls = [item.get("url") for item in result_data if item.get("url")]
                if not urls:
                    raise RuntimeError(
                        f"TokenHub task {task_id} completed but no data[].url: {data}"
                    )
                return urls

            if status == "failed":
                error_info = data.get("error") or {}
                error_msg = error_info.get("message", "unknown error")
                raise RuntimeError(
                    f"TokenHub task {task_id} failed: {error_msg}"
                )

            # queued / running / in_progress — continue polling
            if status not in ("queued", "running", "in_progress"):
                raise RuntimeError(
                    f"TokenHub task {task_id} returned unknown status: {status}"
                )

        raise TimeoutError(
            f"TokenHub task {task_id} did not finish within {timeout_seconds}s"
        )

    # ------------------------------------------------------------------
    # Error handling helpers
    # ------------------------------------------------------------------

    @staticmethod
    def _safe_error(exc: Exception) -> str:
        """Redact secret values from exception messages."""
        msg = str(exc)
        for var in ("TENCENT_TOKENHUB_API_KEY",):
            val = os.environ.get(var, "")
            if val:

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Log the raw status string (included in the message) and check current TokenHub docs for the status lifecycle
  2. If the new status is genuinely non-terminal, add it to the continue-polling tuple in _poll_task
  3. Ensure requests hit the real TokenHub host, not an intermediate proxy that mutates responses
  4. Pin or upgrade the tool version that matches the TokenHub API contract you target

Example fix

# before
if status not in ("queued", "running", "in_progress"):
    raise RuntimeError(...)
# after (example: upstream added 'pending')
if status not in ("queued", "running", "in_progress", "pending"):
    raise RuntimeError(...)
Defensive patterns

Strategy: try-catch

Try / catch

try:
    urls = client._poll_task(task_id, ...)
except RuntimeError as e:
    if "unknown status" in str(e):
        # log the status and consult TokenHub lifecycle docs before patching

Prevention

When it happens

Trigger: 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.

Common situations: API version bump adding a new lifecycle state; custom middleware that rewrites response bodies; testing against a mock server with incorrect status values.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/8fa5acae6964d2c6. Report an issue: GitHub.