Comfy-Org/ComfyUI · error · Exception
Field '{field_name}' cannot be shorter than {min_length} cha
Error message
Field '{field_name}' cannot be shorter than {min_length} characters; was {len(string)} characters long. What it means
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.
Source
Thrown at comfy_api_nodes/util/validation_utils.py:186
if min_duration is not None and dur + eps < min_duration:
raise ValueError(f"Audio duration must be at least {min_duration}s, got {dur + eps:.2f}s")
if max_duration is not None and dur - eps > max_duration:
raise ValueError(f"Audio duration must be at most {max_duration}s, got {dur - eps:.2f}s")
def validate_string(
string: str,
strip_whitespace=True,
field_name="prompt",
min_length=None,
max_length=None,
):
if string is None:
raise Exception(f"Field '{field_name}' cannot be empty.")
if strip_whitespace:
string = string.strip()
if min_length and len(string) < min_length:
raise Exception(
f"Field '{field_name}' cannot be shorter than {min_length} characters; was {len(string)} characters long."
)
if max_length and len(string) > max_length:
raise Exception(
f" Field '{field_name} cannot be longer than {max_length} characters; was {len(string)} characters long."
)
def validate_container_format_is_mp4(video: Input.Video) -> None:
"""Validates video container format is MP4."""
container_format = video.get_container_format()
if container_format not in ["mp4", "mov,mp4,m4a,3gp,3g2,mj2"]:
raise ValueError(f"Only MP4 container format supported. Got: {container_format}")
def _ratio_from_tuple(r: tuple[float, float]) -> float:
a, b = r
if a <= 0 or b <= 0:View on GitHub (pinned to 1c6d8d45b3)
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 ''.
Example fix
# before
validate_string(' ', min_length=1) # Exception: cannot be shorter than 1 characters
# after
validate_string('a cinematic shot of a fox', min_length=1) Defensive patterns
Strategy: validation
Validate before calling
text = (prompt or '').strip()
if not text:
raise ValueError('prompt is empty after stripping whitespace') Type guard
def is_nonempty_text(v) -> bool:
return isinstance(v, str) and len(v.strip()) > 0 Try / catch
try: validate_string(prompt, min_length=1) except Exception as e: raise UserVisibleError(str(e)) from e
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Field '{field_name} cannot be longer than {max_length} char
- The prompt references @Audio{max_tag}, but reference mode is
- Field '{field_name}' cannot be empty.
- Connect at least one keyframe image.
- Spreading {len(images)} images across the clip needs an expl
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/1cca7bd5fef422f6.
Report an issue: GitHub.