nicolargo/glances · warning · HTTPException
Cannot get item {item} for key {key} in plugin view {plugin}
Error message
Cannot get item {item} for key {key} in plugin view {plugin} ({str(e)}) What it means
Raised when the chained lookup get_views().get(key).get(item) fails on the key-views endpoint, returned as HTTP 404. Either the key or the nested item is missing from the views structure (AttributeError/KeyError), and the message names both.
Source
Thrown at glances/outputs/glances_restful_api.py:1195
def _api_key_views(self, plugin: str, item: str, key: str):
"""Glances API RESTful implementation.
Return the JSON view representation of plugin/item/key
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error
"""
self._check_if_plugin_available(plugin)
# Update the stat
self.__update_stats(get_plugin_dependencies(plugin))
try:
# Get the RAW value of the stat views
ret = self.stats.get_plugin(plugin).get_views().get(key).get(item)
except Exception as e:
raise HTTPException(
status.HTTP_404_NOT_FOUND,
f"Cannot get item {item} for key {key} in plugin view {plugin} ({str(e)})",
)
return GlancesJSONResponse(ret)
def _api_item_history(self, plugin: str, item: str, nb: int = 0):
"""Glances API RESTful implementation.
Return the JSON representation of the couple plugin/history of item
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error
"""
self._check_if_plugin_available(plugin)
# Update the statView on GitHub (pinned to a240d8dfb3)
Solutions
- GET /api/4/<plugin>/views and inspect the exact key/item hierarchy
- Use only key/item pairs observed in that response
- Pin or upgrade glances to a version matching the client's expectations
Defensive patterns
Strategy: validation
Validate before calling
views = httpx.get(f'{BASE}/api/4/{plugin}/views').json()
if key in views and item in views.get(key, {}):
ok = True Type guard
def view_path_exists(views: dict, key: str, item: str) -> bool:
return isinstance(views.get(key), dict) and item in views[key] Try / catch
try:
v = httpx.get(f'{BASE}/api/4/{plugin}/{item}/views/{key}').json()
except httpx.HTTPStatusError as e:
if e.response.status_code == 404:
v = None
else:
raise Prevention
- Cache the views tree and validate key/item pairs before requesting
- Do not assume uniform inner fields across view entries
When it happens
Trigger: GET /api/4/<plugin>/<item>/views/<key> where key is not a top-level views entry (then .get(item) runs on None), or item is absent under that key.
Common situations: Clients assuming every views entry has the same inner fields; views schemas differ per plugin and change between glances releases.
Related errors
- Cannot get views ({str(e)})
- Cannot get views for plugin {plugin} ({str(e)})
- Cannot get item {item} for key {key} in plugin {plugin} ({st
- Cannot get item {item} in plugin view {plugin} ({str(e)})
- Cannot get help view data ({str(e)})
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/0e7a795baaac953b.
Report an issue: GitHub.