fix: prevent duplicate packets in API for multi-source deployments (#3051)#3052
Conversation
…ti-source deployments (#3051) The LEFT JOINs on the nodes table were keyed only on nodeNum, but nodes uses a composite PK (nodeNum, sourceId) since migration 029. When the same nodeNum existed in N sources the JOIN multiplied each packet_log row by N, producing 100%-identical duplicate entries in /api/v1/packets responses. The Packet Monitor UI masked the bug by deduplicating by id client-side; direct API consumers received inflated results. Fix: add `AND pl.sourceId = from_nodes.sourceId` (and `to_nodes.sourceId`) to both JOINs in getPacketLogs and getPacketLogById, mirroring the per-source scoping already used by getPacketCountsByNode. Update existing tests to use the production composite-PK schema and add a dedicated regression suite that verifies no duplicate rows are returned when the same nodeNum is present in multiple sources. https://claude.ai/code/session_01BPPK2EUX6W7VwuTEPMYf6G
|
Claude finished @Yeraze's task —— View job PR Review: Fix duplicate packets in multi-source deployments
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-05-17 10:01:07 EDT Test Summary
✅ Overall Result: PASSEDAll deployment configurations are working correctly! Test DetailsConfiguration Import:
Quick Start Test:
Security Test:
V1 API Test:
Reverse Proxy Test:
Reverse Proxy + OIDC Test:
Virtual Node CLI Test:
Backup & Restore Test:
Database Migration Test:
DB Backing Consistency Test:
|

Summary
/api/v1/packets(and the legacy/api/packets) when the samenodeNumexists in multiple sources.getPacketLogsandgetPacketLogByIdjoined thenodestable onnodeNumalone, butnodeshas a composite PK(nodeNum, sourceId)since migration 029 — one packet row was multiplied by the number of sources that knew the node.AND pl.sourceId = from_nodes.sourceId(andto_nodes) to both LEFT JOINs, matching the per-source scoping pattern already used bygetPacketCountsByNode.sourceId).MiscRepository - getPacketLogs / getPacketLogById multi-source dedup (#3051)) with three tests that would have caught this.Closes #3051
Test plan
/api/v1/packetsreturns exactly one row per physical packet in a multi-source deploymentlongNamein API response comes from the correct source (the one that received the packet)https://claude.ai/code/session_01BPPK2EUX6W7VwuTEPMYf6G
Generated by Claude Code