Comfy-Org/ComfyUI · error · ValueError
Positive prompt is too long: {len(prompt)} characters
Error message
Positive prompt is too long: {len(prompt)} characters What it means
Raised by validate_prompts when the positive prompt exceeds the model's max_length (typically 2500 chars for Kling models, lower for some). Client-side length check performed before the API call so Kling never sees an oversized prompt.
Source
Thrown at comfy_api_nodes/nodes_kling.py:286
)
def is_valid_image_response(response: KlingImageGenerationsResponse) -> bool:
"""Verifies that the response contains a task result with at least one image."""
return (
response.data is not None
and response.data.task_result is not None
and response.data.task_result.images is not None
and len(response.data.task_result.images) > 0
)
def validate_prompts(prompt: str, negative_prompt: str, max_length: int) -> bool:
"""Verifies that the positive prompt is not empty and that neither promt is too long."""
if not prompt:
raise ValueError("Positive prompt is empty")
if len(prompt) > max_length:
raise ValueError(f"Positive prompt is too long: {len(prompt)} characters")
if negative_prompt and len(negative_prompt) > max_length:
raise ValueError(
f"Negative prompt is too long: {len(negative_prompt)} characters"
)
return True
def validate_task_creation_response(response) -> None:
"""Validates that the Kling task creation request was successful."""
if not is_valid_task_creation_response(response):
error_msg = f"Kling initial request failed. Code: {response.code}, Message: {response.message}, Data: {response.data}"
logging.error(error_msg)
raise Exception(error_msg)
def validate_video_result_response(response) -> None:
"""Validates that the Kling task result contains a video."""
if not is_valid_video_response(response):View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Shorten the prompt below the model's character limit (2500 for most Kling video nodes)
- Move overflow detail into the negative prompt only if that field has room — no, trim both to fit
- If long context is needed, summarize the prompt with an LLM node before the Kling node
- Show the character count in the UI/node to catch oversize prompts before running
Example fix
// before prompt = full_story_text # 4800 chars // after MAX = 2500 prompt = full_story_text[:MAX] if len(full_story_text) > MAX else full_story_text # or summarize
Defensive patterns
Strategy: validation
Validate before calling
MAX_PROMPT = 2500
def fits(prompt: str) -> bool:
return len(prompt) <= MAX_PROMPT
assert fits(prompt), f"prompt is {len(prompt)} chars, max {MAX_PROMPT}" Type guard
def prompt_within_limit(prompt: str, max_length: int = 2500) -> bool:
return isinstance(prompt, str) and 0 < len(prompt) <= max_length Try / catch
try:
out = await kling_node(prompt=prompt, ...)
except ValueError as e:
if "too long" in str(e):
out = await kling_node(prompt=prompt[:2500], ...)
else:
raise Prevention
- Trim or summarize long prompts before the Kling node
- Surface character counts in prompt-building UIs
- Remember each Kling model/node may pass a different max_length — check the node
When it happens
Trigger: Feeding a Kling node a prompt longer than the max_length passed to validate_prompts — e.g. pasting an entire story, concatenating many prompt fragments, or LLM-generated mega-prompts.
Common situations: Chained prompt-template nodes accumulating text; copying long descriptions from documents; different Kling models having different limits (check the node's limit).
Related errors
- Positive prompt is empty
- Negative prompt is too long: {len(negative_prompt)} characte
- kling-video-o1 only supports durations of 5 or 10 seconds.
- kling-video-o1 does not support audio generation.
- kling-video-o1 does not support 4k resolution.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/b0e5bb3c78cb3f25.
Report an issue: GitHub.