{"record":{"id":"1cca7bd5fef422f6","repo":"Comfy-Org/ComfyUI","slug":"field-field-name-cannot-be-shorter-than-min-l","errorCode":null,"errorMessage":"Field '{field_name}' cannot be shorter than {min_length} characters; was {len(string)} characters long.","messagePattern":"Field '(.+?)' cannot be shorter than (.+?) characters; was (.+?) characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/validation_utils.py","lineNumber":186,"sourceCode":"    if min_duration is not None and dur + eps < min_duration:\n        raise ValueError(f\"Audio duration must be at least {min_duration}s, got {dur + eps:.2f}s\")\n    if max_duration is not None and dur - eps > max_duration:\n        raise ValueError(f\"Audio duration must be at most {max_duration}s, got {dur - eps:.2f}s\")\n\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:","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/validation_utils.py#L168-L204","documentation":"Raised by validate_string() in comfy_api_nodes/util/validation_utils.py when, after optional whitespace stripping, the string is shorter than the node's min_length. Used by dozens of API nodes to enforce provider minimums (usually min_length=1, i.e. non-empty) before spending a request. Note the truthiness of min_length: a min_length of 0 disables the check entirely.","triggerScenarios":"Passing an empty or whitespace-only string to any node calling validate_string(prompt, min_length=1) — Gemini, Kling, LTX, Recraft, Ideogram, Anthropic, etc. Because strip_whitespace defaults to True, a string of only spaces/newlines also triggers it.","commonSituations":"A text widget left blank; a template/prompt-building node emitted only whitespace; a conditioning-to-text conversion produced an empty string; or a user pasted a prompt that was entirely invisible characters. Also common when a workflow's injected variable is empty at runtime.","solutions":["Type actual prompt text into the node's input field or connect a text node with content.","If the prompt is assembled dynamically, add a guard upstream that falls back to a default string when the result is blank.","Check for whitespace-only content (tabs/newlines) — it passes visual inspection but fails after .strip().","Inspect the wire from any text-joining/template node for empty segments producing ''."],"exampleFix":"# before\nvalidate_string('   ', min_length=1)  # Exception: cannot be shorter than 1 characters\n\n# after\nvalidate_string('a cinematic shot of a fox', min_length=1)","handlingStrategy":"validation","validationCode":"text = (prompt or '').strip()\nif not text:\n    raise ValueError('prompt is empty after stripping whitespace')","typeGuard":"def is_nonempty_text(v) -> bool:\n    return isinstance(v, str) and len(v.strip()) > 0","tryCatchPattern":"try: validate_string(prompt, min_length=1) except Exception as e: raise UserVisibleError(str(e)) from e","preventionTips":["Treat whitespace-only as empty — the validator strips before measuring.","Validate template outputs are non-blank before queueing.","Provide fallback prompt text in switch/branch nodes."],"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"}