{"record":{"id":"74dced2c87b36b6d","repo":"calesthio/OpenMontage","slug":"kling-tts-task-failed","errorCode":null,"errorMessage":"Kling TTS task failed","messagePattern":"Kling TTS task failed","errorType":"exception","errorClass":"KlingAPIError","httpStatus":null,"severity":"error","filePath":"tools/audio/kling_tts.py","lineNumber":257,"sourceCode":"        \"\"\"\n        if hasattr(client, \"post\"):\n            data = client.post(request[\"path\"], request[\"payload\"])\n            payload = data.get(\"data\") or {}\n            task_id = payload.get(\"task_id\")\n            if not task_id:\n                raise KlingAPIError(f\"Kling TTS create response missing data.task_id: {data}\")\n\n            task_result = payload.get(\"task_result\") or {}\n            outputs = task_result.get(\"audios\")\n            if outputs is not None:\n                if not isinstance(outputs, list):\n                    raise KlingAPIError(\"Kling TTS result path data.task_result.audios is not a list\")\n                return str(task_id), outputs\n\n            status = payload.get(\"task_status\") or payload.get(\"status\")\n            if status == \"failed\":\n                message = payload.get(\"task_status_msg\") or payload.get(\"message\") or \"Kling TTS task failed\"\n                raise KlingAPIError(str(message), code=payload.get(\"task_status\"), response=data)\n\n            return str(task_id), client.poll_classic(\n                request[\"path\"],\n                str(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        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","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/kling_tts.py#L239-L275","documentation":"Template for a KlingAPIError raised when the create response's task_status/status is 'failed'. The actual message prefers task_status_msg, then message, then this literal default when neither field exists — so seeing the raw text 'Kling TTS task failed' means the failure payload carried no reason fields at all.","triggerScenarios":"Synchronous TTS create returns a terminal failed status immediately: content moderation rejection, invalid voice for the account, or upstream processing error.","commonSituations":"Text failing Kling safety review; voice_id not entitled; rare upstream incidents where the failure body omits task_status_msg/message.","solutions":["When the default text appears, log the full payload — the reason fields are missing and the code+response carry the only clues","Check text content against Kling moderation policies (sensitive words, URLs)","Confirm voice_id entitlement, then retry with a different voice or sanitized text"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = kling_tts_tool.execute(inputs)\nexcept KlingAPIError as e:\n    msg = str(e)\n    if msg == \"Kling TTS task failed\":\n        logger.error(\"kling failed without reason fields; response=%s\", getattr(e, \"response\", None))\n    raise","preventionTips":["Sanitize text (sensitive words, URLs) before submission to pass moderation","Confirm voice entitlement before batch runs","Always log KlingAPIError.response — status_msg fields are sometimes absent"],"tags":["kling","tts","task-failed","moderation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}