calesthio/OpenMontage · error · ValueError

task_id is missing or invalid

Error message

task_id is missing or invalid

What it means

ValueError raised by the static _validate_task_id when the value does not fullmatch SeedanceArkVideo.TASK_ID_PATTERN. Ark content-generation task ids follow a fixed format (cgt-YYYYMMDD-... style); this guard rejects empty strings, None, ids from other providers, or ids with whitespace/extra characters before they are interpolated into query and cancel URLs.

Source

Thrown at tools/video/seedance_ark.py:1351

                )
            time.sleep(interval)

    @staticmethod
    def _download_video(video_url: str, output_path: Path) -> None:
        import requests

        response = requests.get(video_url, timeout=120)
        response.raise_for_status()
        output_path.parent.mkdir(parents=True, exist_ok=True)
        partial = output_path.with_name(output_path.name + ".part")
        partial.write_bytes(response.content)
        partial.replace(output_path)

    @staticmethod
    def _validate_task_id(task_id: Any) -> None:
        value = str(task_id or "")
        if not SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(value):
            raise ValueError("task_id is missing or invalid")

    @staticmethod
    def _raise_for_status(response: Any) -> None:
        try:
            response.raise_for_status()
        except Exception as exc:
            detail = ""
            try:
                payload = response.json()
                error = payload.get("error") if isinstance(payload, dict) else None
                if isinstance(error, dict):
                    detail = ": ".join(
                        str(error.get(key))
                        for key in ("code", "message")
                        if error.get(key)
                    )
            except Exception:
                pass

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Confirm the id came from an Ark (seedance_ark) creation response, not another video provider.
  2. Strip whitespace and check the id is non-empty before calling.
  3. When storing ids from multiple providers, also store the provider name and dispatch on it.
  4. Re-run a valid TASK_ID_PATTERN.fullmatch(value) check in your own code (mirror the pattern from the class) before invoking the tool.

Example fix

# before
result = tool.query(task_id=video_row["external_id"])  # may be a Kling id

# after
if SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(task_id or "")):
    result = tool.query(task_id=task_id)
else:
    result = route_by_provider(video_row)
Defensive patterns

Strategy: type-guard

Validate before calling

from tools.video.seedance_ark import SeedanceArkVideo
if not SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(task_id or "")):
    raise ValueError(f"refusing to query non-Ark task id: {task_id!r}")

Type guard

def is_ark_task_id(v) -> bool:
    from tools.video.seedance_ark import SeedanceArkVideo
    return bool(SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(v or "")))

Try / catch

try:
    tool.query(task_id)
except ValueError as e:
    if "task_id" in str(e):
        logger.error("wrong provider routing for id %r", task_id)
    raise

Prevention

When it happens

Trigger: Passing None, '', a kling task id (e.g. 'kl_...'), a sora video id, or a truncated/copied-with-newline Ark task id to a status-query or cancel operation.

Common situations: Persisting task ids in a generic 'task_id' column shared across providers and routing them to the wrong adapter; deserialization bugs producing empty strings; manual copy-paste from logs picking up trailing spaces.

Related errors


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