{"record":{"id":"6d09a208aed53c5f","repo":"calesthio/OpenMontage","slug":"prompt-is-required-6d09a2","errorCode":null,"errorMessage":"prompt is required","messagePattern":"prompt is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/kling_official_video.py","lineNumber":694,"sourceCode":"            \"video_urls\",\n        ):\n            count += len(inputs.get(key) or [])\n        for key in (\n            \"reference_image_url\",\n            \"reference_image_path\",\n            \"reference_tail_image_url\",\n            \"reference_tail_image_path\",\n            \"reference_video_url\",\n        ):\n            if inputs.get(key):\n                count += 1\n        return count\n\n    @staticmethod\n    def _prompt(inputs: dict[str, Any]) -> str:\n        prompt = str(inputs.get(\"prompt\") or \"\").strip()\n        if not prompt:\n            raise ValueError(\"prompt is required\")\n        return prompt\n\n    @staticmethod\n    def _first_output_url(outputs: list[dict[str, Any]]) -> str:\n        for item in outputs:\n            try:\n                return KlingOfficialVideo._output_url(item)\n            except ValueError:\n                continue\n        raise ValueError(f\"Kling video response contained no downloadable URL: {outputs}\")\n","sourceCodeStart":676,"sourceCodeEnd":705,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/kling_official_video.py#L676-L705","documentation":"Raised by the static `_prompt(inputs)` helper: it reads `inputs['prompt']`, stringifies, strips whitespace, and if the result is empty the call is rejected before any paid Kling request. Kling's generation endpoints require a non-empty text prompt, so this is a deliberate pre-flight check to avoid spending credits on a call the API would reject anyway.","triggerScenarios":"Calling kling_official_video with `prompt` omitted, set to `None`, set to `\"\"`, or containing only whitespace; passing the prompt under a wrong key (e.g. `text` or `description`) so `inputs.get('prompt')` returns nothing.","commonSituations":"Agents composing inputs programmatically where an upstream variable was never filled; prompt-key typos; image-to-video flows where the developer assumed the reference image alone suffices and no prompt is needed (this tool still requires one).","solutions":["Set a non-empty `prompt` string in the inputs dict","If the prompt comes from a variable, add a check that it is non-empty before invoking the tool","Verify the exact key name is `prompt` per the tool's schema — not `text`, `description`, or `negative_prompt`"],"exampleFix":"// before\ninputs = {\"model\": \"kling-v2-master\", \"duration\": 5}\n// after\ninputs = {\"model\": \"kling-v2-master\", \"duration\": 5, \"prompt\": \"A cinematic drone shot over foggy mountains at dawn\"}","handlingStrategy":"validation","validationCode":"prompt = str(inputs.get(\"prompt\") or \"\").strip()\nif not prompt:\n    raise ValueError(\"prompt is required before calling kling_official_video\")","typeGuard":"def has_prompt(inputs: dict) -> bool:\n    return bool(str(inputs.get(\"prompt\") or \"\").strip())","tryCatchPattern":"try:\n    result = kling.execute(inputs)\nexcept ValueError as e:\n    if \"prompt is required\" in str(e):\n        raise RuntimeError(f\"upstream produced empty prompt for inputs keys: {sorted(inputs)}\") from e\n    raise","preventionTips":["Assert a non-empty prompt in your input-builder function, closest to where the prompt originates","When the prompt is model-generated (LLM narration), validate before spend, not after"],"tags":["kling","input-validation","prompt","video-generation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}