{"record":{"id":"0e7a795baaac953b","repo":"nicolargo/glances","slug":"cannot-get-item-item-for-key-key-in-plugin-vie","errorCode":null,"errorMessage":"Cannot get item {item} for key {key} in plugin view {plugin} ({str(e)})","messagePattern":"Cannot get item (.+?) for key (.+?) in plugin view (.+?) \\((.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"glances/outputs/glances_restful_api.py","lineNumber":1195,"sourceCode":"\n    def _api_key_views(self, plugin: str, item: str, key: str):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON view representation of plugin/item/key\n        HTTP/200 if OK\n        HTTP/400 if plugin is not found\n        HTTP/404 if others error\n        \"\"\"\n        self._check_if_plugin_available(plugin)\n\n        # Update the stat\n        self.__update_stats(get_plugin_dependencies(plugin))\n\n        try:\n            # Get the RAW value of the stat views\n            ret = self.stats.get_plugin(plugin).get_views().get(key).get(item)\n        except Exception as e:\n            raise HTTPException(\n                status.HTTP_404_NOT_FOUND,\n                f\"Cannot get item {item} for key {key} in plugin view {plugin} ({str(e)})\",\n            )\n\n        return GlancesJSONResponse(ret)\n\n    def _api_item_history(self, plugin: str, item: str, nb: int = 0):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of the couple plugin/history of item\n        HTTP/200 if OK\n        HTTP/400 if plugin is not found\n        HTTP/404 if others error\n\n        \"\"\"\n        self._check_if_plugin_available(plugin)\n\n        # Update the stat","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L1177-L1213","documentation":"Raised when the chained lookup get_views().get(key).get(item) fails on the key-views endpoint, returned as HTTP 404. Either the key or the nested item is missing from the views structure (AttributeError/KeyError), and the message names both.","triggerScenarios":"GET /api/4/<plugin>/<item>/views/<key> where key is not a top-level views entry (then .get(item) runs on None), or item is absent under that key.","commonSituations":"Clients assuming every views entry has the same inner fields; views schemas differ per plugin and change between glances releases.","solutions":["GET /api/4/<plugin>/views and inspect the exact key/item hierarchy","Use only key/item pairs observed in that response","Pin or upgrade glances to a version matching the client's expectations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"views = httpx.get(f'{BASE}/api/4/{plugin}/views').json()\nif key in views and item in views.get(key, {}):\n    ok = True","typeGuard":"def view_path_exists(views: dict, key: str, item: str) -> bool:\n    return isinstance(views.get(key), dict) and item in views[key]","tryCatchPattern":"try:\n    v = httpx.get(f'{BASE}/api/4/{plugin}/{item}/views/{key}').json()\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 404:\n        v = None\n    else:\n        raise","preventionTips":["Cache the views tree and validate key/item pairs before requesting","Do not assume uniform inner fields across view entries"],"tags":["glances","rest-api","http-404","views","nested-key"],"backgroundTag":"http-404-resource-not-found","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}