Fix: Return empty arrays instead of null for device JSON fields#263
Merged
shamanec merged 2 commits intoshamanec:developfrom Mar 11, 2026
Merged
Fix: Return empty arrays instead of null for device JSON fields#263shamanec merged 2 commits intoshamanec:developfrom
shamanec merged 2 commits intoshamanec:developfrom
Conversation
Frontend crashes with "Cannot read properties of null (reading 'map')" when supported_stream_types or installed_apps are null in JSON responses. Initialize these fields as empty arrays on both hub and provider sides.
Contributor
Author
How to reproduce
Browser consoleAPI response (
|
gifflet
requested changes
Mar 10, 2026
Collaborator
gifflet
left a comment
There was a problem hiding this comment.
I've reviewed the changes and left some comments inline with suggestions for improvement.
- Add models.StreamTypesForOS() to eliminate OS-to-stream-types switch duplication - Replace duplicated switch blocks in hub/devices, hub/router, provider/router - Use unconditional make([]string, 0) for InstalledApps (bson:"-" is always nil from DB) - Remove redundant comments that restated what code already expressed
Collaborator
|
@mogilevich, everything looks good now. @shamanec, any other considerations before approving? |
Owner
|
@mogilevich @gifflet |
shamanec
approved these changes
Mar 11, 2026
Collaborator
|
Yeah, the |
gifflet
approved these changes
Mar 11, 2026
Owner
|
thanks for checking it out @gifflet , thank you for the contribution @mogilevich |
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.
Summary
TypeError: Cannot read properties of null (reading 'map')) on device control page caused bysupported_stream_typesandinstalled_appsbeing serialized asnullinstead of[]in JSON responses.InstalledAppswithmake([]string, 0)inGetInstalledAppsIOSandGetInstalledAppsAndroidso error paths return[]notnull.SupportedStreamTypesbased on device OS in provider'sDeviceInfohandler (was never set on provider side).GetLatestDBDevices.Root cause
In Go,
var s []stringisnil, which serializes to JSONnull. The frontend calls.map()on these fields, which crashes React when they arenull.