Skip to content

api: return empty [] instead of nil systems/channels in /api/v1/scanner#415

Open
trgosk wants to merge 1 commit into
MattCheramie:mainfrom
trgosk:fix-api-scanner-nil-arrays
Open

api: return empty [] instead of nil systems/channels in /api/v1/scanner#415
trgosk wants to merge 1 commit into
MattCheramie:mainfrom
trgosk:fix-api-scanner-nil-arrays

Conversation

@trgosk

@trgosk trgosk commented May 28, 2026

Copy link
Copy Markdown

The web SPA's Systems view crashes with "can't access property 'find', s.systems is null" when the scanner has no hunted systems wired (e.g. cc_hunt disabled, or running a conventional-only setup). The cause is Go's JSON marshalling: a nil []SystemHuntStatusDTO serialises to "null", but the SPA expects "[]" and calls .find()/.map() directly.

Same nil/[] mismatch existed for ConvScannerStatusDTO.Channels when no conventional channels are configured.

Normalise both slices to empty arrays in handleScannerStatus before writing the response. The "scanner == nil" early-return path now also initialises both slices for the same reason.

Verified on a running daemon with cc_hunt disabled and no conventional channels: GET /api/v1/scanner now returns
{"scan_mode":"all","systems":[],"conventional":{...,"channels":[]},...}
and the SPA renders the empty Systems view instead of throwing.

Summary

Changes

Test plan

  • make vet test is green locally
  • make integration is green locally (if the change touches the
    daemon)
  • Added or updated tests where appropriate
  • Smoke-tested against real hardware (if SDR / USB / vocoder code
    changed) — describe the dongle / capture used

Breaking changes

Docs / CHANGELOG

  • Added a ## [Unreleased] bullet to CHANGELOG.md
    if this is user-visible
  • Updated README.md or docs/ if
    operator-facing behaviour changed

Linked issues

The web SPA's Systems view crashes with "can't access property 'find',
s.systems is null" when the scanner has no hunted systems wired (e.g.
cc_hunt disabled, or running a conventional-only setup). The cause is
Go's JSON marshalling: a nil []SystemHuntStatusDTO serialises to "null",
but the SPA expects "[]" and calls .find()/.map() directly.

Same nil/[] mismatch existed for ConvScannerStatusDTO.Channels when no
conventional channels are configured.

Normalise both slices to empty arrays in handleScannerStatus before
writing the response. The "scanner == nil" early-return path now also
initialises both slices for the same reason.

Verified on a running daemon with cc_hunt disabled and no conventional
channels: GET /api/v1/scanner now returns
  {"scan_mode":"all","systems":[],"conventional":{...,"channels":[]},...}
and the SPA renders the empty Systems view instead of throwing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant