nicolargo/glances · warning · HTTPException

Cannot get {item} = {value} for plugin {plugin} ({str(e)})

Error message

Cannot get {item} = {value} for plugin {plugin} ({str(e)})

What it means

Raised when get_raw_stats_value(item, value) fails on the value-filter endpoint, returned as HTTP 404. This endpoint filters list stats by matching a field value (e.g., a process name or mount point); failure means the item/value lookup raised — typically item does not exist or the value cannot be compared.

Source

Thrown at glances/outputs/glances_restful_api.py:1280

    def _api_value(self, plugin: str, item: str, value: str | int | float):
        """Glances API RESTful implementation.

        Return the process stats (dict) for the given item=value
        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
            # TODO in #3211: use a non existing (to be created) get_export_item_value instead but break API
            ret = self.stats.get_plugin(plugin).get_raw_stats_value(item, value)
        except Exception as e:
            raise HTTPException(
                status.HTTP_404_NOT_FOUND, f"Cannot get {item} = {value} for plugin {plugin} ({str(e)})"
            )
        else:
            return GlancesJSONResponse(ret)

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

        Return the JSON representation of the Glances configuration file
        HTTP/200 if OK
        HTTP/404 if others error
        """
        try:
            # Get the RAW value of the config' dict
            args_json = self.config.as_dict() if self.args.password else self.config.as_dict_secure()
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get config ({str(e)})")
        else:

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. Verify the item exists via /api/4/<plugin>/<item>
  2. Ensure the value type matches the field (numbers for numeric fields)
  3. Retry — processlist filtering can race with process exit
  4. URL-encode values containing slashes or special characters
Defensive patterns

Strategy: validation

Validate before calling

sample = httpx.get(f'{BASE}/api/4/{plugin}/{item}').json()
values = [d.get(item) for d in sample] if isinstance(sample, list) else None
# ensures item exists and shows expected value types

Type guard

def value_type_matches(value: str, observed: list) -> bool:
    return any(type(o)(value) is not bool or True for o in observed)

Try / catch

try:
    rows = httpx.get(f'{BASE}/api/4/{plugin}/{item}/{value}').json()
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404:
        rows = []  # no matching entries this cycle
    else:
        raise

Prevention

When it happens

Trigger: GET /api/4/<plugin>/<item>/<method>/value with a nonexistent item or a value whose type doesn't match — e.g., /api/4/processlist/name/python where processlist collection failed, or /api/4/fs/size/abc with a non-numeric comparison.

Common situations: Filtering processlist by a process that exits mid-poll, type mismatches on numeric fields, or item names from a different glances version.

Related errors


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