You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
glances_api/__init__.py line 231 accesses disk['time_since_update'] directly with no
fallback, in the diskio-processing branch of get_ha_sensor_data():
Traced this to Glances' own GlancesPluginModel._manage_rate decorator: time_since_update is
only added to a plugin's stats once a previous sample exists for that plugin
(stats_previous is None on the very first poll after the Glances server process starts, in
which case the decorator returns early without adding the key to any entry). So any diskio poll
that lands in the brief window right after the Glances server (re)starts will omit time_since_update from every disk entry, and this library crashes on it.
Because Home Assistant's DataUpdateCoordinator fails the entire update on any exception raised
while processing coordinator data, this single crash marks every sensor for that Glances
instance unavailable at once -- not just disk sensors, but network/CPU/etc. sensors too, even
though their own code paths are safe.
To Reproduce
Point this library at a Glances v4 server (confirmed on Glances 4.3.1, API v4).
Restart the Glances server process.
Poll get_ha_sensor_data() at the exact moment of the first sample after restart (or shortly
after, before Glances has computed a diskio delta) -- disk["time_since_update"] will be
missing on that poll and raise KeyError.
Expected behavior
The diskio branch should handle a missing time_since_update the same way the network branch
already does -- either version-gate it, or use disk.get("time_since_update") with a sane
fallback (e.g. 0), rather than crashing the whole update.
Environment
glances_api (PyPI glances-api): 0.10.0 (pinned in Home Assistant Core's homeassistant/components/glances/manifest.json)
Home Assistant Core: 2026.7.1 (fully current)
Glances server: 4.3.1, API version 4
Reproduced independently on two separate Glances 4.3.1 hosts
Related
Error with Glances (v4) home-assistant/core#137363 -- reports the same KeyError: 'time_since_update' symptom against
Home Assistant Core, closed "not planned" since the actual bug lives in this library, not in
Home Assistant's own code. Filing here since I couldn't find an existing issue against this repo
for it.
Describe the bug
glances_api/__init__.pyline 231 accessesdisk['time_since_update']directly with nofallback, in the diskio-processing branch of
get_ha_sensor_data():This crashes with
KeyError: 'time_since_update'when a diskio entry lacks that key.By contrast, the network-plugin branch a few lines earlier already handles this correctly by
version-gating the access:
Root cause
Traced this to Glances' own
GlancesPluginModel._manage_ratedecorator:time_since_updateisonly added to a plugin's stats once a previous sample exists for that plugin
(
stats_previous is Noneon the very first poll after the Glances server process starts, inwhich case the decorator returns early without adding the key to any entry). So any diskio poll
that lands in the brief window right after the Glances server (re)starts will omit
time_since_updatefrom every disk entry, and this library crashes on it.Because Home Assistant's
DataUpdateCoordinatorfails the entire update on any exception raisedwhile processing coordinator data, this single crash marks every sensor for that Glances
instance unavailable at once -- not just disk sensors, but network/CPU/etc. sensors too, even
though their own code paths are safe.
To Reproduce
get_ha_sensor_data()at the exact moment of the first sample after restart (or shortlyafter, before Glances has computed a diskio delta) --
disk["time_since_update"]will bemissing on that poll and raise
KeyError.Expected behavior
The diskio branch should handle a missing
time_since_updatethe same way the network branchalready does -- either version-gate it, or use
disk.get("time_since_update")with a sanefallback (e.g.
0), rather than crashing the whole update.Environment
glances-api): 0.10.0 (pinned in Home Assistant Core'shomeassistant/components/glances/manifest.json)Related
KeyError: 'time_since_update'symptom againstHome Assistant Core, closed "not planned" since the actual bug lives in this library, not in
Home Assistant's own code. Filing here since I couldn't find an existing issue against this repo
for it.