nicolargo/glances · error · HTTPException

Cannot get views ({str(e)})

Error message

Cannot get views ({str(e)})

What it means

Raised when getAllViewsAsDict() fails on the views endpoint, returned as HTTP 404. Views describe how each plugin item is displayed; failure means one plugin's view structure could not be built. The message embeds the original exception.

Source

Thrown at glances/outputs/glances_restful_api.py:984

            limits = self.stats.getAllLimitsAsDict()
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get limits ({str(e)})")

        return GlancesJSONResponse(limits)

    def _api_all_views(self):
        """Glances API RESTful implementation.

        Return the JSON representation of all the plugins views
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        try:
            # Get the RAW value of the stat view
            limits = self.stats.getAllViewsAsDict()
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get views ({str(e)})")

        return GlancesJSONResponse(limits)

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

        Return the JSON representation of a given plugin
        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 ID

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. Check the server log for the underlying exception identifying the failing plugin
  2. Upgrade glances fully (core + bundled plugins) to a consistent version
  3. Test per-plugin views via GET /api/4/<plugin>/views to isolate the culprit
Defensive patterns

Strategy: try-catch

Try / catch

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

Prevention

When it happens

Trigger: GET /api/4/all_views when any plugin's get_views() raises — commonly a plugin whose items dict is missing or has an unexpected shape in this glances version.

Common situations: Mixing plugin versions after a partial upgrade, or custom plugins not following the GlancesPlugin views contract.

Related errors


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