api: return empty [] instead of nil systems/channels in /api/v1/scanner#415
Open
trgosk wants to merge 1 commit into
Open
api: return empty [] instead of nil systems/channels in /api/v1/scanner#415trgosk wants to merge 1 commit into
trgosk wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testis green locallymake integrationis green locally (if the change touches thedaemon)
changed) — describe the dongle / capture used
Breaking changes
Docs / CHANGELOG
## [Unreleased]bullet toCHANGELOG.mdif this is user-visible
README.mdordocs/ifoperator-facing behaviour changed
Linked issues