Warn when a node that runs no code names a device
A device on a node without source was accepted and silently ignored. The build now reports it as ignored_device, an advisory issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
@@ -174,6 +174,8 @@ class LoadedNode:
|
||||
#: Published, and with no body of its own — so what runs is the new-node
|
||||
#: template, which returns nothing at all.
|
||||
missing_source: bool = False
|
||||
#: The device this node names although its type never runs on a worker.
|
||||
ignored_device: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -1041,6 +1043,8 @@ class FlowController:
|
||||
node_type = NODE_TYPES.get(node_def.type)
|
||||
if node_type is None:
|
||||
raise ValueError(f"Unknown node type '{node_def.type}'")
|
||||
if node_def.device and not node_type.has_source:
|
||||
entry.ignored_device = node_def.device
|
||||
|
||||
params = resolve_params(node_def.params)
|
||||
|
||||
@@ -1923,6 +1927,22 @@ def _collect_issues(
|
||||
for entry in loaded.values()
|
||||
if entry.missing_source
|
||||
]
|
||||
# Only code travels to a worker, so a device on any other node is a field
|
||||
# nothing reads. Saying so beats a setting that looks like it took.
|
||||
issues += [
|
||||
ValidationIssue(
|
||||
code="ignored_device",
|
||||
message=(
|
||||
f"Node '{entry.id.rpartition('.')[2]}' names device "
|
||||
f"'{entry.ignored_device}', but only a Function node runs on a "
|
||||
"worker. The setting is ignored."
|
||||
),
|
||||
flow=entry.flow,
|
||||
node=entry.id,
|
||||
)
|
||||
for entry in loaded.values()
|
||||
if entry.ignored_device
|
||||
]
|
||||
return issues
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user