From 793c38e78471c43e00b1a4a6b7b24d3c531c5c62 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 12 Mar 2026 11:54:15 -0500 Subject: [PATCH] fix crash when clicking site compound nodes on network map Site compound nodes have IDs like "site_" which can't be cast to binary_id in Ecto queries. Add guard clause to get_node_detail/2 and skip node_clicked events for site nodes in Cytoscape hook. --- assets/js/app.ts | 5 ++++- lib/towerops/topology.ex | 2 ++ test/towerops/topology_test.exs | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/js/app.ts b/assets/js/app.ts index db1fab90..e68a4021 100644 --- a/assets/js/app.ts +++ b/assets/js/app.ts @@ -867,11 +867,14 @@ const NetworkMap = { wheelSensitivity: 1 }) - // Add click handler for nodes + // Add click handler for nodes (skip site compound nodes) this.cy.on('tap', 'node', (evt: any) => { const node = evt.target const nodeData = node.data() + // Don't open detail panel for site group nodes + if (nodeData.type === 'site') return + // Push event to LiveView to open detail panel this.pushEvent("node_clicked", { node_id: nodeData.id, diff --git a/lib/towerops/topology.ex b/lib/towerops/topology.ex index 666e68b4..a1eaa888 100644 --- a/lib/towerops/topology.ex +++ b/lib/towerops/topology.ex @@ -530,6 +530,8 @@ defmodule Towerops.Topology do end end + def get_node_detail("site_" <> _rest, _organization_id), do: nil + def get_node_detail(device_id, organization_id) do device = Repo.one( diff --git a/test/towerops/topology_test.exs b/test/towerops/topology_test.exs index ca6138a7..2f935b43 100644 --- a/test/towerops/topology_test.exs +++ b/test/towerops/topology_test.exs @@ -1362,6 +1362,12 @@ defmodule Towerops.TopologyTest do result = Topology.get_node_detail(Ecto.UUID.generate(), org.id) assert result == nil end + + test "returns nil for site compound node IDs", + %{organization: org, site: site} do + result = Topology.get_node_detail("site_#{site.id}", org.id) + assert result == nil + end end describe "list_connected_devices/1" do