fix(handlers/discovery): nil-guard role in filterPeersByQuery (mc#731) #754

Closed
core-be wants to merge 0 commits from fix/731-nil-guard-filter-peers-by-query into main
Member

Summary

queryPeerMaps sets peer["role"] = nil when the DB role column is empty (discovery.go lines 337-341). filterPeersByQuery did a bare type assertion p["role"].(string) which panics on nil.

Fix: use the comma-ok form so nil → "" (empty string): both name and role fields use x, _ := p["key"].(string) rather than x := p["key"].(string).

Test plan

  • Add TestFilterPeersByQuery_NilRoleRegression with three cases: nil role matches on name, nil name/role with empty q (no-op), all nil — no panic
  • CI discovery tests expected to pass

Regression gate for mc#730/#731.

## Summary queryPeerMaps sets peer["role"] = nil when the DB role column is empty (discovery.go lines 337-341). filterPeersByQuery did a bare type assertion p["role"].(string) which panics on nil. Fix: use the comma-ok form so nil → "" (empty string): both name and role fields use x, _ := p["key"].(string) rather than x := p["key"].(string). ## Test plan - Add TestFilterPeersByQuery_NilRoleRegression with three cases: nil role matches on name, nil name/role with empty q (no-op), all nil — no panic - CI discovery tests expected to pass Regression gate for mc#730/#731.
core-be force-pushed fix/731-nil-guard-filter-peers-by-query from f63e920210 to fe6ada46c2 2026-05-12 17:50:38 +00:00 Compare
core-qa reviewed 2026-05-12 18:16:42 +00:00
core-qa left a comment
Member

[core-qa-agent] APPROVED — PR !754 (fix/731-nil-guard-filter-peers-by-query → main)

Changes Reviewed

workspace-server/internal/handlers/discovery.go (+2/-2):

  • filterPeersByQuery: bare p["name"].(string) / p["role"].(string) → comma-ok form
    • nil → "" — safe when queryPeerMaps sets nil for empty DB role column
    • role, _ := p["role"].(string) // nil → "" with explicit comment ✓

workspace-server/internal/handlers/discovery_test.go (+74/-0):

  • TestFilterPeersByQuery_NilRoleRegression: 3 sub-cases covering nil role/name, empty-q no-op, all-nil no panic ✓
  • Regression gate for mc#730/#731 ✓

Note

PR !731 is the same fix targeting staging (not yet merged). Both branches need to land eventually. When staging merges to main, discovery.go will have a conflict on the same lines — resolve by accepting the incoming version.

Verdict

[core-qa-agent] APPROVED — tests: 1 new test (74 lines), e2e: N/A (backend handler)

[core-qa-agent] APPROVED — PR !754 (fix/731-nil-guard-filter-peers-by-query → main) ## Changes Reviewed **workspace-server/internal/handlers/discovery.go** (+2/-2): - `filterPeersByQuery`: bare `p["name"].(string)` / `p["role"].(string)` → comma-ok form - `nil → ""` — safe when `queryPeerMaps` sets `nil` for empty DB role column - `role, _ := p["role"].(string) // nil → ""` with explicit comment ✓ **workspace-server/internal/handlers/discovery_test.go** (+74/-0): - `TestFilterPeersByQuery_NilRoleRegression`: 3 sub-cases covering nil role/name, empty-q no-op, all-nil no panic ✓ - Regression gate for mc#730/#731 ✓ ## Note PR !731 is the same fix targeting **staging** (not yet merged). Both branches need to land eventually. When staging merges to main, discovery.go will have a conflict on the same lines — resolve by accepting the incoming version. ## Verdict [core-qa-agent] APPROVED — tests: 1 new test (74 lines), e2e: N/A (backend handler)
hongming closed this pull request 2026-05-12 20:17:29 +00:00
Some checks are pending
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 28s
CI / Detect changes (pull_request) Successful in 1m23s
Harness Replays / detect-changes (pull_request) Successful in 18s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 1m23s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m15s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 20s
Required
Details
gate-check-v3 / gate-check (pull_request) Successful in 23s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 43s
qa-review / approved (pull_request) Failing after 18s
security-review / approved (pull_request) Failing after 10s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
sop-checklist-gate / gate (pull_request) Successful in 11s
sop-tier-check / tier-check (pull_request) Successful in 12s
CI / Canvas (Next.js) (pull_request) Successful in 5s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Python Lint & Test (pull_request) Successful in 5s
Harness Replays / Harness Replays (pull_request) Successful in 4s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m24s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 5s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2m12s
Required
Details
CI / Platform (Go) (pull_request) Failing after 7m14s
CI / all-required (pull_request) Failing after 4s
Required
Details
audit-force-merge / audit (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Has been skipped
Required
Details
E2E API Smoke Test / detect-changes (pull_request) Has been skipped
qa-review / approved (pull_request_target)
Required
security-review / approved (pull_request_target)
Required
reserved-path-review / reserved-path-review (pull_request_target)
Required

Pull request closed

Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#754