calesthio/OpenMontage · error · ValueError
text is required
Error message
text is required
What it means
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.
Source
Thrown at tools/audio/kling_tts.py:197
"output_path": str(paths[0]),
"audio_paths": [str(path) for path in paths],
"format": paths[0].suffix.lstrip(".") or "mp3",
"audio_duration_seconds": round(audio_duration, 2) if audio_duration else None,
"cost_estimate_confidence": "low",
"cost_estimate_basis": "Conservative estimate pending official account-usage reconciliation.",
**self._account_usage_result(inputs, client),
**self._callback_result_data(inputs, task_id),
},
artifacts=[str(path) for path in paths],
cost_usd=self.estimate_cost(inputs),
duration_seconds=round(time.time() - start, 2),
model="kling-official-tts",
)
def _build_request(self, inputs: dict[str, Any]) -> dict[str, Any]:
text = str(inputs.get("text") or "").strip()
if not text:
raise ValueError("text is required")
if len(text) > 5000:
raise ValueError("text exceeds Kling TTS safety limit of 5000 characters")
voice_id = str(inputs.get("voice_id") or "").strip()
if not voice_id:
raise ValueError("voice_id is required for Kling official TTS")
voice_language = str(inputs.get("voice_language") or "en")
if voice_language not in TTS_LANGUAGES:
raise ValueError(f"voice_language must be one of: {', '.join(TTS_LANGUAGES)}")
voice_speed = float(inputs.get("voice_speed", 1.0))
if voice_speed < TTS_SPEED_MIN or voice_speed > TTS_SPEED_MAX:
raise ValueError(f"voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_MAX}")
payload: dict[str, Any] = {
"text": text,
"voice_id": voice_id,View on GitHub (pinned to 95e1c3d0ab)
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
Example fix
// before
inputs = {"voice_id": "..."} # no text
// after
inputs = {"text": "Hello world", "voice_id": "..."} Defensive patterns
Strategy: validation
Validate before calling
text = str(inputs.get("text") or "").strip()
if not text:
raise ValueError("text is required for Kling TTS") Type guard
def has_tts_text(inputs: dict) -> bool:
return bool(str(inputs.get("text") or "").strip()) Prevention
- 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
When it happens
Trigger: 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.
Common situations: Template/script variable that rendered empty; segment slicing producing a zero-length chunk; orchestrator passing inputs through unvalidated.
Related errors
- text exceeds Kling TTS safety limit of 5000 characters
- voice_id is required for Kling official TTS
- voice_language must be one of: {', '.join(TTS_LANGUAGES)}
- voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_M
- element_list must be a list of element ids or objects
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/0cff09be37756c85.
Report an issue: GitHub.