nicolargo/glances · error · HTTPException

Cannot get views for plugin {plugin} ({str(e)})

Error message

Cannot get views for plugin {plugin} ({str(e)})

What it means

Raised when get_views() fails for a known plugin, returned as HTTP 404. The availability check passed, so the plugin's view structure itself could not be produced. Original exception is embedded in the message.

Source

Thrown at glances/outputs/glances_restful_api.py:1100

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

        Return the JSON views of a given plugin
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        if plugin not in self.plugins_list:
            raise HTTPException(
                status.HTTP_400_BAD_REQUEST, f"Unknown plugin {plugin} (available plugins: {self.plugins_list})"
            )

        try:
            # Get the RAW value of the stat views
            ret = self.stats.get_plugin(plugin).get_views()
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get views for plugin {plugin} ({str(e)})")

        return GlancesJSONResponse(ret)

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

        Return the JSON 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

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. Inspect the 404 body and server logs for the underlying error
  2. Upgrade/reinstall glances to align plugin and core versions
  3. Isolate by querying other plugins' views
Defensive patterns

Strategy: try-catch

Validate before calling

AVAILABLE = set(httpx.get(f'{BASE}/api/4/plugins').json())
assert plugin in AVAILABLE

Try / catch

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

Prevention

When it happens

Trigger: GET /api/4/<plugin>/views where get_views() raises — e.g., a plugin whose items description dict is malformed after a partial upgrade.

Common situations: Mixed-version installations, or out-of-tree plugins not following the views schema expected by this glances release.

Related errors


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