{"record":{"id":"1e051a6e49a8355c","repo":"calesthio/OpenMontage","slug":"kling-avatar-response-contained-no-videos","errorCode":null,"errorMessage":"Kling avatar response contained no videos","messagePattern":"Kling avatar response contained no videos","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/avatar/kling_avatar.py","lineNumber":285,"sourceCode":"            value=inputs.get(\"sound_file\"),\n            label=\"Avatar audio file\",\n        )\n        if not sound_file:\n            raise ValueError(\"Kling avatar requires audio_id, sound_file, sound_file_url, sound_file_path, or audio_path\")\n        payload[\"sound_file\"] = sound_file\n        return {\n            \"type\": \"sound_file\",\n            \"source\": inputs.get(\"sound_file_url\") or sound_path or \"inline\",\n        }\n\n    def _download_videos(\n        self,\n        client: KlingClient,\n        outputs: list[dict[str, Any]],\n        inputs: dict[str, Any],\n    ) -> list[Path]:\n        if not outputs:\n            raise ValueError(\"Kling avatar response contained no videos\")\n        base_path = Path(inputs.get(\"output_path\", \"kling_avatar.mp4\"))\n        paths: list[Path] = []\n        for index, item in enumerate(outputs):\n            url = self._output_url(item)\n            suffix = extension_from_url(url, \".mp4\")\n            output_path = numbered_output_path(output_path_with_suffix(base_path, suffix), index, suffix)\n            client.download(url, output_path)\n            paths.append(output_path)\n        return paths\n\n    @staticmethod\n    def _output_url(item: dict[str, Any]) -> str:\n        url = item.get(\"url\") or item.get(\"video_url\") or item.get(\"resource_url\")\n        if url:\n            return str(url)\n        resource = item.get(\"resource\") or {}\n        if isinstance(resource, dict) and resource.get(\"url\"):\n            return str(resource[\"url\"])","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/avatar/kling_avatar.py#L267-L303","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Retry the generation once — empty results are occasionally transient.","If the schema moved, update the outputs extraction to read the new key before _download_videos is called.","Check the Kling console for the task status of the failed generation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    paths = tool._download_videos(client, outputs, inputs)\nexcept ValueError as e:\n    if \"no videos\" in str(e):\n        # inspect raw task data for a status/error field; retry once\n        raise","preventionTips":["Check the task status field and any error message in the raw response before attempting download","Retry completed-but-empty tasks once before reporting failure"],"tags":["kling","avatar","api-response","empty-result"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}