mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-10 00:17:16 +08:00
fix: skip non-dict entries in UI-saved prompt JSON
UI-saved workflow JSON stores non-dict metadata keys at the top level (e.g. 'last_node_id', 'last_link_id' as ints). Both validate_prompt and NodeReplaceManager assume every value is a dict, so iterating prompt.items() crashes with TypeError when these keys are present. This is a regression from PR #12595 which tried to fix the same issue but only added 'class_type' check without guarding isinstance. Affected endpoints: /prompt (API submit of UI-saved workflow), and any internal call to validate_prompt / node_replace_manager. Reproducer: open ComfyUI in browser, save workflow (Ctrl+S), then submit via API POST /prompt with that JSON. Previously: 500 TypeError. After: 200 OK (int keys skipped silently). Repro platform-independent (NVIDIA/CUDA users hit it too).
This commit is contained in:
parent
7f287b705e
commit
8429f4ff85
@ -62,7 +62,9 @@ class NodeReplaceManager:
|
|||||||
connections: dict[str, list[tuple[str, str, int]]] = {}
|
connections: dict[str, list[tuple[str, str, int]]] = {}
|
||||||
need_replacement: set[str] = set()
|
need_replacement: set[str] = set()
|
||||||
for node_number, node_struct in prompt.items():
|
for node_number, node_struct in prompt.items():
|
||||||
if "class_type" not in node_struct or "inputs" not in node_struct:
|
if not isinstance(node_struct, dict) or "class_type" not in node_struct or "inputs" not in node_struct:
|
||||||
|
# UI-saved workflow format stores non-dict metadata keys at the top
|
||||||
|
# level (e.g. `last_node_id`, `last_link_id` as ints). Skip them.
|
||||||
continue
|
continue
|
||||||
class_type = node_struct["class_type"]
|
class_type = node_struct["class_type"]
|
||||||
# need replacement if not in NODE_CLASS_MAPPINGS and has replacement
|
# need replacement if not in NODE_CLASS_MAPPINGS and has replacement
|
||||||
|
|||||||
@ -1116,8 +1116,12 @@ def full_type_name(klass):
|
|||||||
async def validate_prompt(prompt_id, prompt, partial_execution_list: Union[list[str], None]):
|
async def validate_prompt(prompt_id, prompt, partial_execution_list: Union[list[str], None]):
|
||||||
outputs = set()
|
outputs = set()
|
||||||
for x in prompt:
|
for x in prompt:
|
||||||
if 'class_type' not in prompt[x]:
|
node_data = prompt[x]
|
||||||
node_data = prompt[x]
|
if not isinstance(node_data, dict):
|
||||||
|
# UI-saved workflow format stores non-dict metadata keys at the top
|
||||||
|
# level (e.g. `last_node_id`, `last_link_id` as ints). Skip them.
|
||||||
|
continue
|
||||||
|
if 'class_type' not in node_data:
|
||||||
node_title = node_data.get('_meta', {}).get('title')
|
node_title = node_data.get('_meta', {}).get('title')
|
||||||
error = {
|
error = {
|
||||||
"type": "missing_node_type",
|
"type": "missing_node_type",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user