nicolargo/glances · warning · HTTPException

Cannot get item {item} in plugin view {plugin} ({str(e)})

Error message

Cannot get item {item} in plugin view {plugin} ({str(e)})

What it means

Raised when get_views().get(item) fails on the item-views endpoint, returned as HTTP 404. Views map display attributes per item; failure usually means the item has no view entry (get returns None or the plugin raised). The embedded exception clarifies.

Source

Thrown at glances/outputs/glances_restful_api.py:1171

    def _api_item_views(self, plugin: str, item: str):
        """Glances API RESTful implementation.

        Return the JSON view representation of the couple plugin/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 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(item)
        except Exception as e:
            raise HTTPException(
                status.HTTP_404_NOT_FOUND,
                f"Cannot get item {item} in plugin view {plugin} ({str(e)})",
            )

        return GlancesJSONResponse(ret)

    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))

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. GET /api/4/<plugin>/views and use exact item keys from the response
  2. Verify the item exists in stats via /api/4/<plugin>/<item>
  3. Align client field names with the deployed glances version
Defensive patterns

Strategy: validation

Validate before calling

views = httpx.get(f'{BASE}/api/4/{plugin}/views').json()
if item not in views:
    print(f'{item} has no view entry')

Type guard

def has_view(item: str, views: dict) -> bool:
    return isinstance(views, dict) and item in views

Try / catch

try:
    v = httpx.get(f'{BASE}/api/4/{plugin}/{item}/views').json()
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404:
        v = None
    else:
        raise

Prevention

When it happens

Trigger: GET /api/4/<plugin>/<item>/views where item is not a key of the plugin's views dict — e.g., an item that exists in stats but has no view definition, or a typo.

Common situations: Querying view metadata for items that are internal/undisplayed, or name mismatches across glances versions.

Related errors


AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27). Data as JSON: /api/errors/4eaf5e71cf5b9463. Report an issue: GitHub.