Skip to content

Conversation

@jaycollett
Copy link
Contributor

@jaycollett jaycollett commented Jan 29, 2026

Summary

Fixes a 500 error that occurs when viewing the dashboard with a Proxmox integration configured. The test() method succeeds but livestats() 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

  • Add null check in apiCall() before calling ->getBody() on potentially null response
  • Check nodeData for null before passing to array_map()
  • Add null checks for node_status, vm_stats, and container_stats before accessing properties
  • Track valid_nodes count to prevent division by zero when calculating CPU average
  • Use null coalescing (??) for optional properties like cpu and memory
  • Add check to prevent division by zero when memory_total is 0
  • Return "inactive" status gracefully instead of crashing
  • Pass default $inactiveData array with zero values to getLiveStats() for inactive returns - the view template requires these variables to render

Testing

  • Tested with valid API token and proper permissions - stats display correctly
  • Tested with connection failures - gracefully shows inactive instead of 500 error
  • Tested with partial data - handles missing properties without crashing
  • Tested inactive status rendering - view displays zeros instead of undefined variable errors

Related Issue

Fixes linuxserver/Heimdall#1533

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.
@jaycollett jaycollett force-pushed the fix/proxmox-livestats-null-handling branch from 68f7180 to e7fcd04 Compare January 29, 2026 18:41
@mvdkleijn
Copy link
Collaborator

Sorry for the delay. I was busy working on https://opencommit.eu related stuff. Merging.

@mvdkleijn mvdkleijn merged commit 7cc7336 into linuxserver:master Feb 2, 2026
3 checks passed
@LinuxServer-CI LinuxServer-CI moved this from PRs to Done in Issue & PR Tracker Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Proxmox integration not returning data

2 participants