{"record":{"id":"bfe403afbb748c6e","repo":"Comfy-Org/ComfyUI","slug":"maximum-max-count-reference-images-are-allowed","errorCode":null,"errorMessage":"Maximum {max_count} reference images are allowed.","messagePattern":"Maximum (.+?) reference images are allowed\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_luma.py","lineNumber":695,"sourceCode":"            optional=True,\n            tooltip=f\"Up to {max_image_refs} reference images for style/content guidance.\",\n        ),\n    ]\n\n\nasync def _luma2_upload_image_refs(\n    cls: type[IO.ComfyNode],\n    refs: dict | None,\n    max_count: int,\n) -> list[Luma2ImageRef] | None:\n    if not refs:\n        return None\n    out: list[Luma2ImageRef] = []\n    for key in refs:\n        url = await upload_image_to_comfyapi(cls, refs[key])\n        out.append(Luma2ImageRef(url=url))\n    if len(out) > max_count:\n        raise ValueError(f\"Maximum {max_count} reference images are allowed.\")\n    return out or None\n\n\nasync def _luma2_submit_and_poll(\n    cls: type[IO.ComfyNode],\n    request: Luma2GenerationRequest,\n    *,\n    estimated_duration: int | None = None,\n) -> Luma2Generation:\n    \"\"\"Submit a Luma Agents generation and poll until done; returns the completed generation.\"\"\"\n    initial = await sync_op(\n        cls,\n        ApiEndpoint(path=\"/proxy/luma_2/generations\", method=\"POST\"),\n        response_model=Luma2Generation,\n        data=request,\n    )\n    if not initial.id:\n        raise RuntimeError(\"Luma API did not return a generation id.\")","sourceCodeStart":677,"sourceCodeEnd":713,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_luma.py#L677-L713","documentation":"Raised by _luma2_upload_image_refs (comfy_api_nodes/nodes_luma.py:695) when more reference images are supplied than the target Luma 2 / Ray endpoint allows (max_count, e.g. 9 for image refs). Note the check runs after every ref has already been uploaded, so the error also wastes upload time and bandwidth.","triggerScenarios":"Passing a refs dict (image_ref chain input) with more entries than max_count — e.g. 10+ Luma image-reference nodes chained into LumaImageNode2's image_ref input.","commonSituations":"Users chain many reference-image nodes believing more refs improve style fidelity; a workflow copied from a different node with a higher limit; duplicates accidentally added while editing a chain.","solutions":["Count the chained image-ref nodes and reduce them to at most max_count (9 for Luma image refs).","Remove duplicate or lowest-value reference images from the chain.","If you hit this often, pre-validate len(refs) in your own wrapper node before executing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"MAX_REFS = 9\nif refs and len(refs) > MAX_REFS:\n    raise ValueError(f\"Too many Luma image refs: {len(refs)} > {MAX_REFS}; trim the chain before executing\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Count chained image-ref nodes before queueing; the limit (max_count) varies by node, 9 for Luma image refs.","Note the node uploads all refs before checking, so catching it early also saves upload bandwidth."],"tags":["luma","reference-images","input-validation","comfy-api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}