Comfy-Org/ComfyUI · error · ValueError

Negative prompt is too long: {len(negative_prompt)} characte

Error message

Negative prompt is too long: {len(negative_prompt)} characters

What it means

Raised by validate_prompts when the negative prompt is non-empty and exceeds max_length. Unlike the positive prompt, an empty negative is fine; only an over-long non-empty one fails. Client-side check, no network involved.

Source

Thrown at comfy_api_nodes/nodes_kling.py:288

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):
        error_msg = f"Kling task {response.data.task_id} succeeded but no video data found in response."
        logging.error("Error: %s.\nResponse: %s", error_msg, response)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Trim the negative prompt to the model's character limit
  2. Deduplicate and remove redundant terms from the negative blocklist
  3. Leave the negative prompt empty if the model (e.g. newer Kling models) largely ignores it

Example fix

// before
negative_prompt = giant_blocklist  # 3000 chars

// after
negative_prompt = giant_blocklist[:2500]
Defensive patterns

Strategy: validation

Validate before calling

MAX_PROMPT = 2500

if negative_prompt:
    negative_prompt = negative_prompt[:MAX_PROMPT]

Type guard

def negative_prompt_ok(neg: str | None, max_length: int = 2500) -> bool:
    return not neg or len(neg) <= max_length

Try / catch

try:
    out = await kling_node(prompt=prompt, negative_prompt=neg, ...)
except ValueError as e:
    if "Negative prompt is too long" in str(e):
        out = await kling_node(prompt=prompt, negative_prompt=neg[:2500], ...)
    else:
        raise

Prevention

When it happens

Trigger: Passing a negative prompt longer than the model limit — commonly a huge blocklist of terms accumulated from shared workflows or prompt presets.

Common situations: Copy-pasted 'universal negative prompt' lists from prompt-sharing sites that exceed the limit; merging multiple negative prompt outputs.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/cb71797d9716563b. Report an issue: GitHub.