{"record":{"id":"7a56ced8c46c4702","repo":"calesthio/OpenMontage","slug":"kling-lip-sync-response-contained-no-videos","errorCode":null,"errorMessage":"Kling lip-sync response contained no videos","messagePattern":"Kling lip-sync response contained no videos","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/avatar/kling_lip_sync.py","lineNumber":658,"sourceCode":"            value=inputs.get(\"sound_file\"),\n            label=\"Lip-sync audio file\",\n        )\n        if not sound_file:\n            raise ValueError(\"advanced_lip_sync 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 lip-sync response contained no videos\")\n        base_path = Path(inputs.get(\"output_path\", \"kling_lip_sync.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":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/avatar/kling_lip_sync.py#L640-L676","documentation":"Raised by KlingLipSyncTool._download_videos when the Kling task response's outputs list is empty (or falsy). The task reached the download stage but returned zero video entries — typically a failed or partially-failed generation that still reported completion, or an unexpected response shape.","triggerScenarios":"Polling a Kling advanced/full lip-sync task whose final status contains no outputs array entries; a callback-driven flow where the callback payload lacked video data; upstream API change renaming the outputs field so the tool sees [].","commonSituations":"Kling-side generation failure reported as success; content-policy or audio-length rejections that produce no video; intermittent API quirks; version drift in the Kling response schema.","solutions":["Retry the task once — transient upstream failures sometimes produce empty outputs","Inspect the full task response (status, error message fields) before the tool's download step to see the real Kling-side status/error","Check that the audio meets Kling constraints (>=2s crop, valid format) and the face selection was valid","If it persists, capture the raw response and report as a tool/API issue"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"resp = client.wait_for_task(task_id)\nif not resp.get(\"outputs\"):\n    log.warning(\"empty outputs; task status=%s msg=%s\", resp.get(\"status\"), resp.get(\"msg\"))","typeGuard":null,"tryCatchPattern":"try:\n    paths = tool._download_videos(client, outputs, inputs)\nexcept ValueError as e:\n    if \"no videos\" in str(e) and attempt < MAX_RETRIES:\n        outputs = client.wait_for_task(task_id, force_refresh=True).get(\"outputs\", [])\n        continue  # retry once with fresh task state\n    raise","preventionTips":["Verify task status and any error/message fields before downloading","Retry once — transient empty outputs happen","Validate audio length and face selection up front to avoid Kling-side rejections"],"tags":["kling","lip-sync","api-response","empty-result"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}