Comfy-cli crash at end of execution but not comfyui
Hi,
I'm executing my workflow api json file like this:
comfy run --workflow workflow.json --wait --timeout 3600 --verbose
The execution is started whiteout any problem.
But at the end of the execution, comfy-cli is crashing with error:
KeyError: '406.0.0.428'
Which seems to be 2 nodes id: 406 and 428. But in the logs of comfy-ui everything went well. I can see the log "Prompt executed in XXXs". Which for me means that everything went well, as I can't see any error in comfy-ui logs. Plus my images are saved correctly, and save image are the last nodes of the workflow.
406 and 428 node are coming from: https://github.com/WainWong/ComfyUI-Loop-image.
comfyui: 0.3.39 (tried also on 0.3.29) comfy-cli: latest python: 3.10
comfy-ui install command:
comfy --skip-prompt --no-enable-telemetry --workspace /comfyui install --fast-deps --nvidia --version 0.3.39
root@runc:/mnt/code# comfy run --workflow workflow.json --wait --timeout 3600 --verbose
Executing workflow: /mnt/code/workflow.json
XXXXX
....
Executing : Batch Image Loop Open๐ฐ - CyberEve_BatchImageLoopOpen (428)
....
Executing : Batch Image Loop Close๐ฐ - CyberEve_BatchImageLoopClose (406)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโบโโโโโโโโโโโโ 68% 0:02:50
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Traceback (most recent call last) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/tracking.py:77 in wrapper โ
โ โ
โ 74 โ โ โ logging.debug(f"Tracking command: {command_name} with arguments: {filtered_k โ
โ 75 โ โ โ track_event(command_name, properties=filtered_kwargs) โ
โ 76 โ โ โ โ
โ โฑ 77 โ โ โ return func(*args, **kwargs) โ
โ 78 โ โ โ
โ 79 โ โ return wrapper โ
โ 80 โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๏ฟฝ๏ฟฝโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ args = () โ โ
โ โ command_name = 'run' โ โ
โ โ filtered_kwargs = {'workflow': 'workflow.json', 'wait': True, 'verbose': True, 'host': None, 'port': None, 'timeout': 3600, 'cli_version': '1.4.0', 'tracing_id': 'e0dc5c45-1d51-4a31-8a92-018ac5b86c26'} โ โ
โ โ kwargs = {'workflow': 'workflow.json', 'wait': True, 'verbose': True, 'host': None, 'port': None, 'timeout': 3600} โ โ
โ โ sub_command = None โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/cmdline.py:444 in run โ
โ โ
โ 441 โ if not port: โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ 442 โ โ port = 8188 โ config = <comfy_cli.config_manager.ConfigManager object at 0x7fca4c198eb0> โ โ
โ 443 โ โ host = '127.0.0.1' โ โ
โ โฑ 444 โ run_inner.execute(workflow, host, port, wait, verbose, local_paths, timeout) โ local_paths = False โ โ
โ 445 โ port = 8188 โ โ
โ 446 โ timeout = 3600 โ โ
โ 447 def validate_comfyui(_env_checker): โ verbose = True โ โ
โ โ wait = True โ โ
โ โ workflow = 'workflow.json' โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๏ฟฝ๏ฟฝโโโโโโโโโโโโโโโฏ โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/command/run.py:73 in execute โ
โ โ
โ 70 โ โ โ execution.connect() โ
โ 71 โ โ execution.queue() โ
โ 72 โ โ if wait: โ
โ โฑ 73 โ โ โ execution.watch_execution() โ
โ 74 โ โ โ end = time.time() โ
โ 75 โ โ โ progress.stop() โ
โ 76 โ โ โ progress = None โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ execution = <comfy_cli.command.run.WorkflowExecution object at 0x7fca4ba7b4c0> โ โ
โ โ host = '127.0.0.1' โ โ
โ โ local_paths = False โ โ
โ โ port = 8188 โ โ
โ โ progress = <comfy_cli.command.run.ExecutionProgress object at 0x7fca4ba7a4a0> โ โ
โ โ start = 1748602747.9621973 โ โ
โ โ timeout = 3600 โ โ
โ โ verbose = True โ โ
โ โ wait = True โ โ
โ โ workflow = {XXX}
โ โ workflow_name = '/mnt/code/workflow.json' โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/command/run.py:165 in watch_execution โ
โ โ
โ 162 โ โ โ message = self.ws.recv() โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ 163 โ โ โ if isinstance(message, str): โ message = {'type': 'executing', 'data': {'node': '406.0.0.428', 'display_node': '428', 'prompt_id': '680e5783-c32e-476d-8ee9-e2eb6110f661'}} โ โ
โ 164 โ โ โ โ message = json.loads(message) โ self = <comfy_cli.command.run.WorkflowExecution object at 0x7fca4ba7b4c0> โ โ
โ โฑ 165 โ โ โ โ if not self.on_message(message): โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ 166 โ โ โ โ โ break โ
โ 167 โ ๏ฟฝ๏ฟฝ๏ฟฝ
โ 168 โ def update_overall_progress(self): โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/command/run.py:213 in on_message โ
โ โ
โ 210 โ โ โ return True โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ 211 โ โ โ data = {'node': '406.0.0.428', 'display_node': '428', 'prompt_id': '680e5783-c32e-476d-8ee9-e2eb6110f661'} โ โ
โ 212 โ โ if message["type"] == "executing": โ message = {'type': 'executing', 'data': {'node': '406.0.0.428', 'display_node': '428', 'prompt_id': '680e5783-c32e-476d-8ee9-e2eb6110f661'}} โ โ
โ โฑ 213 โ โ โ return self.on_executing(data) โ self = <comfy_cli.command.run.WorkflowExecution object at 0x7fca4ba7b4c0> โ โ
โ 214 โ โ elif message["type"] == "execution_cached": โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ 215 โ โ โ self.on_cached(data) โ
โ 216 โ โ elif message["type"] == "progress": โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/command/run.py:237 in on_executing โ
โ โ
โ 234 โ โ โ โ self.remaining_nodes.discard(self.current_node) โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ 235 โ โ โ โ self.update_overall_progress() โ data = {'node': '406.0.0.428', 'display_node': '428', 'prompt_id': '680e5783-c32e-476d-8ee9-e2eb6110f661'} โ โ
โ 236 โ โ โ self.current_node = data["node"] โ self = <comfy_cli.command.run.WorkflowExecution object at 0x7fca4ba7b4c0> โ โ
โ โฑ 237 โ โ โ self.log_node("Executing", data["node"]) โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ 238 โ โ return True โ
โ 239 โ โ
โ 240 โ def on_cached(self, data): โ
โ โ
โ /usr/local/lib/python3.10/site-packages/comfy_cli/command/run.py:181 in log_node โ
โ โ
โ 178 โ โ if not self.verbose: โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโ๏ฟฝ๏ฟฝโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ 179 โ โ โ return โ node_id = '406.0.0.428' โ โ
โ 180 โ โ โ self = <comfy_cli.command.run.WorkflowExecution object at 0x7fca4ba7b4c0> โ โ
โ โฑ 181 โ โ node = self.workflow[node_id] โ type = 'Executing' โ โ
โ 182 โ โ class_type = node["class_type"] โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ 183 โ โ title = self.get_node_title(node_id) โ
โ 184 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
KeyError: '406.0.0.428'
To Reproduce working on giving an example.
Expected behavior Not to crash
Nice to have
- [ ] Terminal output
- [ ] Screenshots
Additional context Workflow was working perfectly in comfy-ui web interface.
Hi @BowgartField! I'm Dosu and Iโm helping the comfy-cli team.
The KeyError '406.0.0.428' in comfy-cli happens because the CLI tries to access a node in your workflow dictionary using that exact key, but it doesn't exist. This is likely due to how node IDs are handled between comfy-cli and the ComfyUI server: if the server sends a node ID (like '406.0.0.428') that isn't present in your workflow JSON, comfy-cli will crash with a KeyError instead of handling the situation gracefully. This is a limitation in comfy-cli's error handlingโthere is no defensive check for missing node IDs, so any mismatch or unexpected node reference from the server will cause a crash rather than a user-friendly error message. In contrast, comfy-ui's web interface may be more tolerant or simply not surface this issue in the same way, which is why you see no errors there and your images are saved as expected.
To resolve or work around this issue:
- Double-check your
workflow.jsonto ensure all node IDs referenced during execution exist as top-level keys in the workflow dictionary. - If you see composite node IDs like
'406.0.0.428', investigate whether any custom nodes (such as those from ComfyUI-Loop-image) are generating or referencing IDs in a way that comfy-cli does not expect. - As a workaround, you could manually inspect or preprocess your workflow JSON to ensure all referenced node IDs are present, or avoid using node configurations that result in composite IDs until comfy-cli improves its error handling.
Currently, comfy-cli does not have built-in validation or error handling for this scenario, so any missing or malformed node ID will result in a crash rather than a helpful error message. Improving this would require changes to the CLI code to check for node existence before attempting to access it and to provide a clearer error if not found. For now, careful validation of your workflow JSON and awareness of how custom nodes generate IDs is the best way to avoid this issue.
Reference: comfy-cli WorkflowExecution node handling
To reply, just mention my name @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report ๐ | Otherย ย ย
@dosu I just rewrite my workflow to change Image-Loop nodes to just Easy-Use nodes, but got the same problem. It seems link to any nodes that involves loop mechanism. So for me this is a real bug
You're correctโthis does look like a real bug in comfy-cli's handling of workflows that use any kind of loop mechanism. The root cause is that comfy-cli expects every node ID referenced during execution to exist as a top-level key in your workflow JSON. When a loop mechanism is used, the ComfyUI server sometimes sends composite or unexpected node IDs (like '406.0.0.428'), which do not exist in the workflow dictionary. This leads to an unhandled KeyError and a crash, even though the workflow runs fine in the ComfyUI web interface and all outputs are saved as expected.
This is a limitation in comfy-cli's error handling: there is no defensive check for missing node IDs, so any mismatch or unexpected reference from the server will cause a crash instead of a user-friendly error message. The code does not currently validate or gracefully handle these cases, and there is no evidence of a workaround or fix in the codebase or open issues at this time. The CLI simply assumes all node IDs it receives will be present in the workflow, which is not always true for workflows involving loops or certain custom nodes. Reference: comfy-cli WorkflowExecution node handling
Until comfy-cli adds more robust error handling for this scenario, the only workaround is to avoid node configurations that result in these composite IDs, or to preprocess your workflow JSON to ensure all referenced node IDs are present (which is not always practical or possible). If you need to use loop mechanisms, this limitation will likely persist until the CLI is updated to handle these cases more gracefully.
If you have a minimal example workflow that triggers this, sharing it could help the maintainers reproduce and address the bug.
To reply, just mention my name @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report ๐ | Otherย ย ย