{"record":{"id":"2e7969daa195c8b9","repo":"calesthio/OpenMontage","slug":"kling-tts-response-contained-no-audios","errorCode":null,"errorMessage":"Kling TTS response contained no audios","messagePattern":"Kling TTS response contained no audios","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/audio/kling_tts.py","lineNumber":283,"sourceCode":"            )\n\n        task_id = client.create_classic_task(request[\"path\"], request[\"payload\"])\n        return task_id, client.poll_classic(\n            request[\"path\"],\n            task_id,\n            \"audios\",\n            timeout_seconds=int(inputs.get(\"timeout_seconds\", 300)),\n            poll_interval=float(inputs.get(\"poll_interval\", 3.0)),\n        )\n\n    def _download_audios(\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 TTS response contained no audios\")\n        base_path = Path(inputs.get(\"output_path\", \"kling_tts.mp3\"))\n        paths: list[Path] = []\n        for index, item in enumerate(outputs):\n            url = self._output_url(item)\n            suffix = extension_from_url(url, \".mp3\")\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(\"audio_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":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/kling_tts.py#L265-L301","documentation":"Raised as ValueError by _download_audios when the outputs list from the create response or polling is empty (falsy). The task nominally succeeded and returned an audios array, but it contains zero entries, so there is nothing to download.","triggerScenarios":"poll_classic returns an empty 'audios' list on success; synchronous create returns task_result.audios: []; shape change yielding an empty container instead of null.","commonSituations":"Upstream bug or partial success returning an empty array; polling helper that returns a default empty list when its extraction key misses; silent moderation drop of all audio segments.","solutions":["Log the raw outputs value and the last poll response to distinguish 'empty from API' vs 'extraction miss'","Retry the create — empty-audio success is usually transient","If poll_classic extracts by key, verify the key name matches the current response shape"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if not outputs:\n    raise ValueError(\"kling returned zero audios; retry the create call\")","typeGuard":"def has_audios(outputs: Any) -> bool:\n    return isinstance(outputs, list) and len(outputs) > 0","tryCatchPattern":"try:\n    result = kling_tts_tool.execute(inputs)\nexcept ValueError as e:\n    if \"no audios\" in str(e):\n        result = kling_tts_tool.execute(inputs)  # one retry: empty-success is transient\n    else:\n        raise","preventionTips":["Treat empty-audios-on-success as retryable","Verify poll_classic's extraction key matches the live response shape","Log the final poll response when the error fires"],"tags":["kling","tts","empty-result","download"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}