{"record":{"id":"3184bc85784b2b1a","repo":"Comfy-Org/ComfyUI","slug":"field-field-name-cannot-be-longer-than-max-le","errorCode":null,"errorMessage":" Field '{field_name} cannot be longer than {max_length} characters; was {len(string)} characters long.","messagePattern":" Field '(.+?) cannot be longer than (.+?) characters; was (.+?) characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/validation_utils.py","lineNumber":190,"sourceCode":"\n\ndef validate_string(\n    string: str,\n    strip_whitespace=True,\n    field_name=\"prompt\",\n    min_length=None,\n    max_length=None,\n):\n    if string is None:\n        raise Exception(f\"Field '{field_name}' cannot be empty.\")\n    if strip_whitespace:\n        string = string.strip()\n    if min_length and len(string) < min_length:\n        raise Exception(\n            f\"Field '{field_name}' cannot be shorter than {min_length} characters; was {len(string)} characters long.\"\n        )\n    if max_length and len(string) > max_length:\n        raise Exception(\n            f\" Field '{field_name} cannot be longer than {max_length} characters; was {len(string)} characters long.\"\n        )\n\n\ndef validate_container_format_is_mp4(video: Input.Video) -> None:\n    \"\"\"Validates video container format is MP4.\"\"\"\n    container_format = video.get_container_format()\n    if container_format not in [\"mp4\", \"mov,mp4,m4a,3gp,3g2,mj2\"]:\n        raise ValueError(f\"Only MP4 container format supported. Got: {container_format}\")\n\n\ndef _ratio_from_tuple(r: tuple[float, float]) -> float:\n    a, b = r\n    if a <= 0 or b <= 0:\n        raise ValueError(f\"Ratios must be positive, got {a}:{b}.\")\n    return a / b\n\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/validation_utils.py#L172-L208","documentation":"Raised by validate_string() in comfy_api_nodes/util/validation_utils.py when the string exceeds the node's max_length (checked after whitespace stripping). Providers cap prompt sizes (Heygen 1000/5000, Recraft 1000, Kling 2500, LTX 10000, Meshy 600...), and this guard fails locally instead of after upload. Note the message has cosmetic bugs — a leading space and a missing closing quote after the field name — but it fires correctly.","triggerScenarios":"Passing a long prompt to any node calling validate_string(prompt, max_length=N): a 1500-char prompt into Recraft (max 1000), a 4000-char Heygen script into a 1000-char field, or a huge pasted document into a Kling text box (2500).","commonSituations":"Users paste whole scripts/articles as prompts; prompt-template chains concatenate context until the string overruns; or a workflow tuned for one provider (LTX 10000) is reused with a stricter one (Meshy 600). Also triggered by LoRA-style prompt dumps including weighting syntax that the target API does not use anyway.","solutions":["Shorten the prompt below the node's documented limit (see the node tooltip or provider API docs).","If you need long context, switch to a provider node with a larger cap (e.g. text/LLM nodes) or summarize first with a local LLM node.","Strip ComfyUI-specific syntax (weights, LoRA tags) that the target API ignores and that inflate length.","When concatenating template segments, count characters before the API node and truncate deterministically."],"exampleFix":"# before\nvalidate_string(long_script, field_name='prompt', min_length=1, max_length=1000)\n# Exception when len(long_script) > 1000\n\n# after\nvalidate_string(long_script[:1000], field_name='prompt', min_length=1, max_length=1000)","handlingStrategy":"validation","validationCode":"MAX = 1000  # per node/provider\nif len(text) > MAX:\n    text = text[:MAX]","typeGuard":null,"tryCatchPattern":"try: validate_string(prompt, max_length=MAX) except Exception as e: raise UserVisibleError(str(e)) from e","preventionTips":["Count characters before pasting long scripts into capped prompt fields.","Strip ComfyUI-specific syntax the target API ignores.","Sum lengths when concatenating template segments."],"tags":["api-nodes","validation","prompt","string-length"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}