{"record":{"id":"73d959c14d36058a","repo":"nicolargo/glances","slug":"cannot-get-stats-str-e","errorCode":null,"errorMessage":"Cannot get stats ({str(e)})","messagePattern":"Cannot get stats \\((.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":952,"sourceCode":"    # Comment this solve an issue on Home Assistant See #3238\n    def _api_all(self):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of all the plugins\n        HTTP/200 if OK\n        HTTP/400 if plugin is not found\n        HTTP/404 if others error\n        \"\"\"\n\n        # Update the stat\n        self.__update_stats()\n\n        try:\n            # Get the RAW value of the stat ID\n            # TODO in #3211: use getAllExportsAsDict instead but break UI for uptime, processlist, others ?\n            statval = self.stats.getAllAsDict()\n        except Exception as e:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Cannot get stats ({str(e)})\")\n\n        return GlancesJSONResponse(statval)\n\n    def _api_all_limits(self):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of all the plugins limits\n        HTTP/200 if OK\n        HTTP/400 if plugin is not found\n        HTTP/404 if others error\n        \"\"\"\n        try:\n            # Get the RAW value of the stat limits\n            limits = self.stats.getAllLimitsAsDict()\n        except Exception as e:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Cannot get limits ({str(e)})\")\n\n        return GlancesJSONResponse(limits)","sourceCodeStart":934,"sourceCodeEnd":970,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L934-L970","documentation":"Raised when getAllAsDict() fails while building the full stats dump, returned as HTTP 404. Any single plugin raising during serialization of the combined stats payload triggers this. The underlying exception message is appended.","triggerScenarios":"GET /api/4/all when any plugin's stats serialization raises — e.g., a plugin accessing a missing sysfs/procfs file, or a GPU/NPU library (pynvml) erroring mid-collection.","commonSituations":"Containerized or Snap-confined environments where /proc or /sys paths are unreadable, transient errors from hardware-monitoring plugins, or a plugin dependency missing at runtime.","solutions":["Poll individual plugin endpoints (GET /api/4/plugins then /api/4/<plugin>) to isolate the failing plugin","Check server logs for the underlying exception name embedded in the 404 body","Disable the failing plugin with --disable-plugin <name> as a workaround","Ensure required dependencies and host file access exist (especially for gpu, sensors plugins)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"r = httpx.get(f'{BASE}/api/4/all')\nif r.status_code != 200:\n    # fall back to per-plugin fetch\n    plugins = httpx.get(f'{BASE}/api/4/plugins').json()","typeGuard":null,"tryCatchPattern":"try:\n    stats = httpx.get(f'{BASE}/api/4/all', timeout=10).json()\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 404:\n        stats = {p: httpx.get(f'{BASE}/api/4/{p}').json()\n                 for p in httpx.get(f'{BASE}/api/4/plugins').json()}\n    else:\n        raise","preventionTips":["Retry once before falling back — collection errors are often transient","Isolate failing plugins with per-plugin requests"],"tags":["glances","rest-api","http-404","stats-dump"],"backgroundTag":"http-404-resource-not-found","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}