Skip to content

Commit 44ed8e4

Browse files
committed
Warn on prompt inputs that match no declared node input
Keys in a node's inputs that do not match any declared required or optional input were silently dropped, with no log entry, error, or history record. Diff the received input keys against the declared ones after building valid_inputs and log a warning naming the node and the ignored keys.
1 parent b963f4a commit 44ed8e4

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

execution.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,10 @@ async def validate_inputs(prompt_id, prompt, item, validated, visiting=None):
895895

896896
valid_inputs = set(class_inputs.get('required',{})).union(set(class_inputs.get('optional',{})))
897897

898+
unknown_inputs = set(inputs) - valid_inputs
899+
if unknown_inputs:
900+
logging.warning(f"Node {unique_id} ({class_type}): ignoring unknown input(s) {', '.join(sorted(unknown_inputs))}")
901+
898902
for x in valid_inputs:
899903
input_type, input_category, extra_info = get_input_info(obj_class, x, class_inputs)
900904
assert extra_info is not None
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import asyncio
2+
import logging
3+
4+
from comfy.cli_args import args as cli_args
5+
6+
cli_args.cpu = True
7+
8+
import nodes # noqa: E402
9+
import execution # noqa: E402
10+
11+
12+
class StubNodeForUnknownInputTest:
13+
@classmethod
14+
def INPUT_TYPES(cls):
15+
return {"required": {"a": ("INT", {})}}
16+
17+
RETURN_TYPES = ()
18+
FUNCTION = "go"
19+
CATEGORY = "test"
20+
21+
def go(self, a):
22+
return ()
23+
24+
25+
def test_unknown_input_is_warned_and_ignored(monkeypatch, caplog):
26+
monkeypatch.setitem(nodes.NODE_CLASS_MAPPINGS, "StubNodeForUnknownInputTest", StubNodeForUnknownInputTest)
27+
prompt = {
28+
"1": {
29+
"class_type": "StubNodeForUnknownInputTest",
30+
"inputs": {"a": 1, "ref_audios": {"ref_audio_0": ["2", 0]}},
31+
}
32+
}
33+
34+
with caplog.at_level(logging.WARNING):
35+
valid, errors, node_id = asyncio.run(execution.validate_inputs("test-prompt", prompt, "1", {}))
36+
37+
assert valid
38+
assert errors == []
39+
assert any("ref_audios" in record.message for record in caplog.records)

0 commit comments

Comments
 (0)