Fix Proxmox livestats 500 error with null handling#888
Merged
mvdkleijn merged 2 commits intolinuxserver:masterfrom Feb 2, 2026
Merged
Fix Proxmox livestats 500 error with null handling#888mvdkleijn merged 2 commits intolinuxserver:masterfrom
mvdkleijn merged 2 commits intolinuxserver:masterfrom
Conversation
The livestats() method would crash with a 500 error when: - API calls returned null (connection failures, permission issues) - Node status/VM/container data was missing expected properties - Division by zero when no valid nodes were found Changes: - Add null check in apiCall() before calling getBody() - Check nodeData for null before array_map() - Add null checks for node_status, vm_stats, and container_stats - Track valid_nodes count to prevent division by zero - Use null coalescing for optional properties (cpu, memory) - Return "inactive" status gracefully instead of crashing Fixes linuxserver/Heimdall#1533
The livestats.blade.php view requires variables like $vm_running, $cpu_percent, etc. When returning "inactive" status, we were passing an empty array which caused undefined variable errors. Now passing $inactiveData with default zero values so the view renders properly even when the API is unreachable or returns no data.
68f7180 to
e7fcd04
Compare
Collaborator
|
Sorry for the delay. I was busy working on https://opencommit.eu related stuff. Merging. |
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
Fixes a 500 error that occurs when viewing the dashboard with a Proxmox integration configured. The
test()method succeeds butlivestats()crashes due to missing null checks.Root cause: The
livestats()method doesn't handle cases where API calls return null (connection failures, insufficient permissions, or malformed responses), causing fatal errors when accessing properties on null.Changes
apiCall()before calling->getBody()on potentially null responsenodeDatafor null before passing toarray_map()node_status,vm_stats, andcontainer_statsbefore accessing propertiesvalid_nodescount to prevent division by zero when calculating CPU average??) for optional properties likecpuandmemorymemory_totalis 0$inactiveDataarray with zero values togetLiveStats()for inactive returns - the view template requires these variables to renderTesting
Related Issue
Fixes linuxserver/Heimdall#1533