calesthio/OpenMontage · error · ValueError

Kling avatar response contained no videos

Error message

Kling avatar response contained no videos

What it means

ValueError from KlingAvatarTool._download_videos when the completed task's outputs list is empty. The API call succeeded and polling finished, but the result contained zero video entries — typically a partially-failed multi-output generation or an unexpected response shape where the videos live under a different key.

Source

Thrown at tools/avatar/kling_avatar.py:285

            value=inputs.get("sound_file"),
            label="Avatar audio file",
        )
        if not sound_file:
            raise ValueError("Kling avatar requires audio_id, sound_file, sound_file_url, sound_file_path, or audio_path")
        payload["sound_file"] = sound_file
        return {
            "type": "sound_file",
            "source": inputs.get("sound_file_url") or sound_path or "inline",
        }

    def _download_videos(
        self,
        client: KlingClient,
        outputs: list[dict[str, Any]],
        inputs: dict[str, Any],
    ) -> list[Path]:
        if not outputs:
            raise ValueError("Kling avatar response contained no videos")
        base_path = Path(inputs.get("output_path", "kling_avatar.mp4"))
        paths: list[Path] = []
        for index, item in enumerate(outputs):
            url = self._output_url(item)
            suffix = extension_from_url(url, ".mp4")
            output_path = numbered_output_path(output_path_with_suffix(base_path, suffix), index, suffix)
            client.download(url, output_path)
            paths.append(output_path)
        return paths

    @staticmethod
    def _output_url(item: dict[str, Any]) -> str:
        url = item.get("url") or item.get("video_url") or item.get("resource_url")
        if url:
            return str(url)
        resource = item.get("resource") or {}
        if isinstance(resource, dict) and resource.get("url"):
            return str(resource["url"])

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Inspect the full task data captured in the run (raw response) to see where video URLs actually live and whether an error field explains the empty list.
  2. Retry the generation once — empty results are occasionally transient.
  3. If the schema moved, update the outputs extraction to read the new key before _download_videos is called.
  4. Check the Kling console for the task status of the failed generation.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    paths = tool._download_videos(client, outputs, inputs)
except ValueError as e:
    if "no videos" in str(e):
        # inspect raw task data for a status/error field; retry once
        raise

Prevention

When it happens

Trigger: Kling returns taskResult with an empty or missing videos array; the response parsing that produces 'outputs' looked at the wrong JSON key for this gateway version; generation produced no video due to a content/moderation issue reported elsewhere in the payload.

Common situations: Kling silently dropping a generation that failed content review; gateway schema drift moving videos under a nested key; race where download starts before the result payload is fully populated.

Related errors


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