{"record":{"id":"7fc6b6e29ef5ac38","repo":"Comfy-Org/ComfyUI","slug":"positive-prompt-is-empty","errorCode":null,"errorMessage":"Positive prompt is empty","messagePattern":"Positive prompt is empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_kling.py","lineNumber":284,"sourceCode":"        and response.data.task_result.videos is not None\n        and len(response.data.task_result.videos) > 0\n    )\n\n\ndef is_valid_image_response(response: KlingImageGenerationsResponse) -> bool:\n    \"\"\"Verifies that the response contains a task result with at least one image.\"\"\"\n    return (\n        response.data is not None\n        and response.data.task_result is not None\n        and response.data.task_result.images is not None\n        and len(response.data.task_result.images) > 0\n    )\n\n\ndef validate_prompts(prompt: str, negative_prompt: str, max_length: int) -> bool:\n    \"\"\"Verifies that the positive prompt is not empty and that neither promt is too long.\"\"\"\n    if not prompt:\n        raise ValueError(\"Positive prompt is empty\")\n    if len(prompt) > max_length:\n        raise ValueError(f\"Positive prompt is too long: {len(prompt)} characters\")\n    if negative_prompt and len(negative_prompt) > max_length:\n        raise ValueError(\n            f\"Negative prompt is too long: {len(negative_prompt)} characters\"\n        )\n    return True\n\n\ndef validate_task_creation_response(response) -> None:\n    \"\"\"Validates that the Kling task creation request was successful.\"\"\"\n    if not is_valid_task_creation_response(response):\n        error_msg = f\"Kling initial request failed. Code: {response.code}, Message: {response.message}, Data: {response.data}\"\n        logging.error(error_msg)\n        raise Exception(error_msg)\n\n\ndef validate_video_result_response(response) -> None:","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_kling.py#L266-L302","documentation":"Raised by validate_prompts when the positive prompt is empty (falsy) before the Kling request is sent. This is a client-side pre-flight check: Kling requires a non-empty positive prompt, so the node refuses to make the call. It fires before any network traffic.","triggerScenarios":"Calling a Kling text-to-video/image node with prompt='' or a prompt that is None — e.g. an unconnected prompt input in the workflow, or an upstream node producing an empty string.","commonSituations":"Workflow wiring mistake where the prompt node output isn't connected; a template/concat node emitting empty text; programmatic API runs passing an empty string.","solutions":["Provide a non-empty prompt string to the node's prompt input","Check the workflow graph: confirm the node feeding the prompt actually outputs text","If building prompts dynamically, guard with a default or skip when the composed prompt is blank"],"exampleFix":"// before\nprompt = \"\"  # unconnected or empty upstream\n\n// after\nprompt = prompt or \"a cinematic drone shot of a coastal city at sunset\"","handlingStrategy":"validation","validationCode":"def check_prompt(prompt: str) -> None:\n    if not prompt or not prompt.strip():\n        raise ValueError(\"prompt must be a non-empty string\")\n\ncheck_prompt(prompt)","typeGuard":"def has_valid_prompt(prompt) -> bool:\n    return isinstance(prompt, str) and len(prompt.strip()) > 0","tryCatchPattern":"try:\n    out = await kling_node(prompt=prompt, ...)\nexcept ValueError as e:\n    if \"Positive prompt is empty\" in str(e):\n        out = await kling_node(prompt=DEFAULT_PROMPT, ...)\n    else:\n        raise","preventionTips":["Connect the prompt input in the workflow graph before running","Default empty prompts to a fallback string at the workflow entry point","Assert prompt truthiness in programmatic runs before calling the node"],"tags":["kling","validation","prompt","pre-flight"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}