nicolargo/glances · warning · HTTPException

Cannot get {item} description for plugin {plugin} ({str(e)})

Error message

Cannot get {item} description for plugin {plugin} ({str(e)})

What it means

Raised when get_item_info(item, 'description') fails on the item-description endpoint, returned as HTTP 404. Item metadata comes from the plugin's items description dict; failure means the item is unknown to that metadata (or the plugin raised).

Source

Thrown at glances/outputs/glances_restful_api.py:1238

            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get history for plugin {plugin} ({str(e)})")
        else:
            return GlancesJSONResponse(ret)

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

        Return the JSON representation of the couple plugin/item description
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        self._check_if_plugin_available(plugin)

        try:
            # Get the description
            ret = self.stats.get_plugin(plugin).get_item_info(item, 'description')
        except Exception as e:
            raise HTTPException(
                status.HTTP_404_NOT_FOUND, f"Cannot get {item} description for plugin {plugin} ({str(e)})"
            )
        else:
            return GlancesJSONResponse(ret)

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

        Return the JSON representation of the couple plugin/item unit
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        self._check_if_plugin_available(plugin)

        try:
            # Get the unit
            ret = self.stats.get_plugin(plugin).get_item_info(item, 'unit')

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. GET /api/4/<plugin>/views or /api/4/<plugin> to see known items
  2. Treat 404 on description as 'no description available' and fall back to a default label
  3. Upgrade glances so item descriptions match stats fields

Example fix

# before
label = fetch(f'/api/4/cpu/{item}/description')  # raises 404
# after
resp = fetch(f'/api/4/cpu/{item}/description')
label = resp.json() if resp.ok else item  # graceful fallback
Defensive patterns

Strategy: fallback

Validate before calling

views = httpx.get(f'{BASE}/api/4/{plugin}/views').json()
has_desc = item in views

Type guard

def has_description(item: str, views: dict) -> bool:
    return item in views

Try / catch

r = httpx.get(f'{BASE}/api/4/{plugin}/{item}/description')
desc = r.json() if r.status_code == 200 else item  # fall back to raw name

Prevention

When it happens

Trigger: GET /api/4/<plugin>/<item>/description with an item absent from the plugin's items descriptions — commonly a valid stat key that has no registered description, or a typo.

Common situations: New stat fields added in a glances release before their descriptions, or clients enumerating stats keys and blindly requesting descriptions for all of them.

Related errors


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