Comfy-Org/ComfyUI · error · ValueError
At least one image is required for editing.
Error message
At least one image is required for editing.
What it means
Dict-driven Grok image edit node requires at least one connected image: it collects non-None tensors from model['images'], sums their image counts, and n_images < 1 raises. All image sockets empty (or explicitly None) means the edit request would have no source image, which the xAI edits endpoint cannot process.
Source
Thrown at comfy_api_nodes/nodes_grok.py:584
@classmethod
async def execute(
cls,
prompt: str,
model: dict,
seed: int,
) -> IO.NodeOutput:
validate_string(prompt, strip_whitespace=True, min_length=1)
model_id = model["model"]
resolution = model["resolution"]
number_of_images = model["number_of_images"]
images_dict = model.get("images") or {}
aspect_ratio = model.get("aspect_ratio", "auto")
image_tensors: list[Input.Image] = [t for t in images_dict.values() if t is not None]
n_images = sum(get_number_of_images(t) for t in image_tensors)
max_images = _GROK_IMAGE_EDIT_MAX_IMAGES.get(model_id, 3)
if n_images < 1:
raise ValueError("At least one image is required for editing.")
if n_images > max_images:
raise ValueError(
f"The {model_id} model supports at most {max_images} input "
f"image{'s' if max_images > 1 else ''}; {n_images} are connected."
)
if aspect_ratio != "auto" and model_id in _GROK_IMAGE_EDIT_ASPECT_RATIO_NEEDS_MULTIPLE and n_images == 1:
raise ValueError(
"Custom aspect ratio is only allowed when multiple images are connected to the image input."
)
flat_tensors: list[torch.Tensor] = []
for tensor in image_tensors:
if len(tensor.shape) == 4:
flat_tensors.extend(tensor[i] for i in range(tensor.shape[0]))
else:
flat_tensors.append(tensor)
response = await sync_op(View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Connect at least one image to the node's image input(s).
- Verify the upstream image node actually produced output (not None/empty).
- Use a text-to-image Grok node if no source image is intended.
Example fix
# before
model['images'] = {} # nothing connected -> raises
await grok_edit_execute(model, seed=1)
# after
model['images'] = {'image_1': load_image('src.png')}
await grok_edit_execute(model, seed=1) Defensive patterns
Strategy: validation
Validate before calling
n = sum(get_number_of_images(t) for t in (model.get("images") or {}).values() if t is not None)
assert n >= 1, "connect at least one image to the edit node" Prevention
- Check upstream image nodes produce non-None output before running the edit.
- Use a generation (not edit) node when no source image is intended.
- Fail workflows early when the images dict is empty.
When it happens
Trigger: Executing the model-dict grok image edit with model['images'] empty or every value None — nothing wired into any image socket.
Common situations: Workflow saved with image inputs that reference missing files; upstream node silently produced an empty dict; users attempting prompt-only generation through an edit node instead of a generation node.
Related errors
- The pro model supports only 1 input image.
- A maximum of 3 input images is supported.
- Custom aspect ratio is only allowed when multiple images are
- The {model_id} model supports at most {max_images} input ima
- The prompt references @Image{idx}, but only {total_images} r
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/2bc6069b9e194f1d.
Report an issue: GitHub.