mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-10 12:05:22 +03:00
Add list type check before nodes[0] access in _normalize_link_nodes
This commit is contained in:
parent
0d45bfbae5
commit
10ff5b2283
@ -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 "
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user