{"record":{"id":"5ccbe7d8b00254fb","repo":"calesthio/OpenMontage","slug":"kling-tts-create-response-missing-data-task-id-d","errorCode":null,"errorMessage":"Kling TTS create response missing data.task_id: {data}","messagePattern":"Kling TTS create response missing data\\.task_id: (.+?)","errorType":"exception","errorClass":"KlingAPIError","httpStatus":null,"severity":"error","filePath":"tools/audio/kling_tts.py","lineNumber":245,"sourceCode":"\n    @staticmethod\n    def _create_and_collect_audios(\n        client: KlingClient,\n        request: dict[str, Any],\n        inputs: dict[str, Any],\n    ) -> tuple[str, list[dict[str, Any]]]:\n        \"\"\"Create a TTS task and return audio outputs.\n\n        Official TTS may return a completed task and task_result.audios[]\n        directly from POST /v1/audio/tts. Older/async behavior still requires\n        polling GET /v1/audio/tts/{task_id}, so support both shapes.\n        \"\"\"\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)),","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/kling_tts.py#L227-L263","documentation":"Raised as KlingAPIError when the POST /v1/audio/tts response's data object has no task_id. The client considers a create without task_id unrecoverable because both the synchronous path (task_result.audios) and the polling path key off it. The full response body is embedded for diagnosis.","triggerScenarios":"API returns an error envelope that still passed the client's status checks (code treated as success), an envelope version change moving task_id elsewhere, or data: null on a soft auth/account failure.","commonSituations":"Kling API version bump changing the response shape; account not entitled for TTS returning an unusual body; gateway response replaced by a different JSON structure.","solutions":["Read the embedded response body — it usually contains the real upstream code/message","Verify KLING_API_KEY/KLING_ACCESS_KEY entitlements include audio TTS","Retry once for transient soft failures","If the envelope changed, update the extraction path in _execute_with_client"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = kling_tts_tool.execute(inputs)\nexcept KlingAPIError as e:\n    if \"missing data.task_id\" in str(e):\n        logger.error(\"kling create envelope unexpected: %s\", getattr(e, \"response\", None))\n        raise\n    raise","preventionTips":["Verify KLING API credentials are entitled for /v1/audio/tts","Log full create responses during integration to catch envelope drift early","Centralize Kling calls so one retry/diagnostic path covers all tools"],"tags":["kling","tts","api-contract","task-id"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}