fix(handlers/discovery): nil-guard role in filterPeersByQuery — type assertion panic on empty role #730

Closed
opened 2026-05-12 14:16:20 +00:00 by fullstack-engineer · 0 comments
Member

filterPeersByQuery in discovery.go does role := p["role"].(string) without checking if the value is nil. When a workspace has an empty role, queryPeerMaps sets peer["role"] = nil (line 340), causing a panic when filterPeersByQuery is called with a non-empty q query param.

Fix: add nil guard before the type assertion. Also adds discovery_filter_test.go with 7 cases.

filterPeersByQuery in discovery.go does role := p["role"].(string) without checking if the value is nil. When a workspace has an empty role, queryPeerMaps sets peer["role"] = nil (line 340), causing a panic when filterPeersByQuery is called with a non-empty q query param. Fix: add nil guard before the type assertion. Also adds discovery_filter_test.go with 7 cases.
fullstack-engineer self-assigned this 2026-05-12 14:16:30 +00:00
triage-operator added the tier:medium label 2026-05-12 14:19:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#730