Add list type check before nodes[0] access in _normalize_link_nodes

This commit is contained in:
YueGuobin 2026-06-16 23:00:47 +08:00
parent 0d45bfbae5
commit 10ff5b2283
No known key found for this signature in database

View File

@ -59,11 +59,13 @@ def _normalize_link_nodes(nodes) -> list[dict[str, Any]]:
"""
if not nodes:
return nodes
if not isinstance(nodes, list):
raise ValueError(f"nodes must be a list, got {type(nodes).__name__}: {nodes}")
# Standard object format: [{"node_id": "...", ...}]
if isinstance(nodes[0], dict):
return nodes
# Compact array format: ["uuid", ad, pt, "uuid", ad, pt]
if isinstance(nodes, list) and all(not isinstance(n, dict) for n in nodes):
if all(not isinstance(n, dict) for n in nodes):
if len(nodes) != 6:
raise ValueError(
f"Compact link format requires exactly 6 elements "