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 added 1 commit 2026-05-12 17:47:50 +00:00
fix(handlers/discovery): nil-guard role in filterPeersByQuery (mc#731)
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 14s
Harness Replays / detect-changes (pull_request) Successful in 12s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 22s
CI / Detect changes (pull_request) Successful in 29s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 12s
E2E API Smoke Test / detect-changes (pull_request) Successful in 31s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 30s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 19s
qa-review / approved (pull_request) Failing after 18s
security-review / approved (pull_request) Failing after 17s
gate-check-v3 / gate-check (pull_request) Successful in 28s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 33s
sop-checklist-gate / gate (pull_request) Successful in 17s
sop-tier-check / tier-check (pull_request) Successful in 15s
Harness Replays / Harness Replays (pull_request) Successful in 7s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 9s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 4s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 1m11s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 5s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m21s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m30s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m45s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 3m38s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 3m44s
CI / Platform (Go) (pull_request) Failing after 7m27s
CI / all-required (pull_request) Failing after 2s
f63e920210
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 now use x, _ := p["key"].(string) rather than x := p["key"].(string).

Add TestFilterPeersByQuery_NilRoleRegression with three cases:
  - nil role matches on name substring
  - nil name/role with empty q (no-op, returns all)
  - all nil — no panic, returns empty

Regression gate for mc#730/#731.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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 failed
CI / Platform (Go) (pull_request) Failing after 7m14s
CI / all-required (pull_request) Failing after 4s
Required
Details
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
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
Required
Details
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
audit-force-merge / audit (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Has been skipped
E2E API Smoke Test / detect-changes (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No description provided.