Fix Proxmox livestats 500 error with null handling #888
+53
−21
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