Comfy-Org/ComfyUI · error · Exception
Field '{field_name}' cannot be empty.
Error message
Field '{field_name}' cannot be empty. What it means
Raised by validate_string() in comfy_api_nodes/util/validation_utils.py when the string input (default field name 'prompt') is None. It is a plain Exception (not ValueError) raised before any API call, so workflow users see it as node execution failure. Nearly every text-input API node (Gemini, OpenAI, Kling, Recraft, LTX, etc.) routes prompts through this helper.
Source
Thrown at comfy_api_nodes/util/validation_utils.py:182
) -> None:
sr = int(audio["sample_rate"])
dur = int(audio["waveform"].shape[-1]) / sr
eps = 1.0 / sr
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}")
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Set an actual string on the node's text input — type the prompt or connect a text-producing node.
- If building the prompt API-side, guard upstream: ensure the key exists and is a non-None string before queueing.
- Check the immediately upstream node for None output (e.g. an interrogate/caption node that failed silently) and fix or bypass it.
- If None is legitimately possible in your workflow, branch on it with a switch node that substitutes a placeholder string.
Example fix
# before validate_string(None, field_name='prompt') # Exception: Field 'prompt' cannot be empty. # after validate_string(prompt or '', field_name='prompt') # or simply ensure prompt is a real string before the call
Defensive patterns
Strategy: type-guard
Validate before calling
if prompt is None:
raise ValueError('prompt input is unset') Type guard
def is_prompt_text(v) -> bool:
return isinstance(v, str) Try / catch
try: validate_string(prompt, field_name='prompt') except Exception as e: raise UserVisibleError(str(e)) from e
Prevention
- Default text widgets to a placeholder instead of leaving them unset.
- When building prompts programmatically, assert the key exists and is a str.
- Check upstream text nodes for silent None outputs.
When it happens
Trigger: A node's text input is literally None — e.g. an optional upstream conditioning/text node produced None, a Python caller invoked the node function with prompt=None, or a widget value was left unset in a programmatically built workflow JSON.
Common situations: Workflows assembled by scripts where the 'prompt' key is omitted from inputs dict (the node receives None via INPUT_TYPES defaults), or a text node whose upstream supplier returned None (empty caption, failed extraction). Also seen when combo widgets are switched and the stored value becomes invalid.
Related errors
- The prompt references @Audio{max_tag}, but reference mode is
- Field '{field_name}' cannot be shorter than {min_length} cha
- Field '{field_name} cannot be longer than {max_length} char
- 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/3c639bf4da001e4c.
Report an issue: GitHub.