{"record":{"id":"0cff09be37756c85","repo":"calesthio/OpenMontage","slug":"text-is-required","errorCode":null,"errorMessage":"text is required","messagePattern":"text is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/audio/kling_tts.py","lineNumber":197,"sourceCode":"                \"output_path\": str(paths[0]),\n                \"audio_paths\": [str(path) for path in paths],\n                \"format\": paths[0].suffix.lstrip(\".\") or \"mp3\",\n                \"audio_duration_seconds\": round(audio_duration, 2) if audio_duration else None,\n                \"cost_estimate_confidence\": \"low\",\n                \"cost_estimate_basis\": \"Conservative estimate pending official account-usage reconciliation.\",\n                **self._account_usage_result(inputs, client),\n                **self._callback_result_data(inputs, task_id),\n            },\n            artifacts=[str(path) for path in paths],\n            cost_usd=self.estimate_cost(inputs),\n            duration_seconds=round(time.time() - start, 2),\n            model=\"kling-official-tts\",\n        )\n\n    def _build_request(self, inputs: dict[str, Any]) -> dict[str, Any]:\n        text = str(inputs.get(\"text\") or \"\").strip()\n        if not text:\n            raise ValueError(\"text is required\")\n        if len(text) > 5000:\n            raise ValueError(\"text exceeds Kling TTS safety limit of 5000 characters\")\n\n        voice_id = str(inputs.get(\"voice_id\") or \"\").strip()\n        if not voice_id:\n            raise ValueError(\"voice_id is required for Kling official TTS\")\n\n        voice_language = str(inputs.get(\"voice_language\") or \"en\")\n        if voice_language not in TTS_LANGUAGES:\n            raise ValueError(f\"voice_language must be one of: {', '.join(TTS_LANGUAGES)}\")\n\n        voice_speed = float(inputs.get(\"voice_speed\", 1.0))\n        if voice_speed < TTS_SPEED_MIN or voice_speed > TTS_SPEED_MAX:\n            raise ValueError(f\"voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_MAX}\")\n\n        payload: dict[str, Any] = {\n            \"text\": text,\n            \"voice_id\": voice_id,","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/kling_tts.py#L179-L215","documentation":"Raised by kling_tts._build_request when inputs['text'] is missing, empty, or whitespace-only after stripping. It is the first of five sequential validations on the TTS payload (text presence, length cap, voice_id, language, speed), and runs before any HTTP call.","triggerScenarios":"Calling the kling_official_tts tool with no text key, text: '', or text consisting only of whitespace; also triggered upstream if a caller forwards an empty script segment.","commonSituations":"Template/script variable that rendered empty; segment slicing producing a zero-length chunk; orchestrator passing inputs through unvalidated.","solutions":["Supply non-empty text in inputs","Guard upstream: skip or merge empty text segments before invoking the tool","Log the inputs (minus secrets) when the error fires to find which stage produced empty text"],"exampleFix":"// before\ninputs = {\"voice_id\": \"...\"}  # no text\n\n// after\ninputs = {\"text\": \"Hello world\", \"voice_id\": \"...\"}","handlingStrategy":"validation","validationCode":"text = str(inputs.get(\"text\") or \"\").strip()\nif not text:\n    raise ValueError(\"text is required for Kling TTS\")","typeGuard":"def has_tts_text(inputs: dict) -> bool:\n    return bool(str(inputs.get(\"text\") or \"\").strip())","tryCatchPattern":null,"preventionTips":["Skip or merge empty segments before invoking the tool","Assert required keys at the orchestrator boundary","Render scripts with a linter that rejects empty template variables"],"tags":["kling","tts","validation","input-required"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}