{"record":{"id":"3c639bf4da001e4c","repo":"Comfy-Org/ComfyUI","slug":"field-field-name-cannot-be-empty","errorCode":null,"errorMessage":"Field '{field_name}' cannot be empty.","messagePattern":"Field '(.+?)' cannot be empty\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/validation_utils.py","lineNumber":182,"sourceCode":") -> None:\n    sr = int(audio[\"sample_rate\"])\n    dur = int(audio[\"waveform\"].shape[-1]) / sr\n    eps = 1.0 / sr\n    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","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/validation_utils.py#L164-L200","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nvalidate_string(None, field_name='prompt')  # Exception: Field 'prompt' cannot be empty.\n\n# after\nvalidate_string(prompt or '', field_name='prompt')\n# or simply ensure prompt is a real string before the call","handlingStrategy":"type-guard","validationCode":"if prompt is None:\n    raise ValueError('prompt input is unset')","typeGuard":"def is_prompt_text(v) -> bool:\n    return isinstance(v, str)","tryCatchPattern":"try: validate_string(prompt, field_name='prompt') except Exception as e: raise UserVisibleError(str(e)) from e","preventionTips":["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."],"tags":["api-nodes","validation","prompt","null-check"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}