{"record":{"id":"ed3c5d305b57e000","repo":"nicolargo/glances","slug":"unknown-argument-item-item","errorCode":null,"errorMessage":"Unknown argument item {item}","messagePattern":"Unknown argument item (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":1409,"sourceCode":"        HTTP/404 if others error\n        \"\"\"\n        try:\n            args_json = self._sanitize_args()\n        except Exception as e:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Cannot get args ({str(e)})\")\n\n        return GlancesJSONResponse(args_json)\n\n    def _api_args_item(self, item: str):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of the Glances command line arguments item\n        HTTP/200 if OK\n        HTTP/400 if item is not found\n        HTTP/404 if others error\n        \"\"\"\n        if item not in self.args:\n            raise HTTPException(status.HTTP_400_BAD_REQUEST, f\"Unknown argument item {item}\")\n\n        try:\n            args_json = self._sanitize_args()[item]\n        except Exception as e:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Cannot get args item ({str(e)})\")\n\n        return GlancesJSONResponse(args_json)\n\n    def _api_set_extended_processes(self, pid: str):\n        \"\"\"Glances API RESTful implementation.\n\n        Set the extended process stats for the given PID\n        HTTP/200 if OK\n        HTTP/400 if PID is not found\n        HTTP/404 if others error\n        \"\"\"\n        process_stats = glances_processes.get_stats(int(pid))\n","sourceCodeStart":1391,"sourceCodeEnd":1427,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L1391-L1427","documentation":"HTTP 400 raised by GET /api/4/args/{item} when the requested name is not an attribute of the Glances args namespace. The check is 'item not in self.args', i.e. membership on the argparse Namespace's __dict__, so any option name Glances was actually started with is accepted and anything else is rejected.","triggerScenarios":"GET /api/4/args/foo when --foo is not a Glances CLI option, or when querying an option added in a newer Glances version than the one serving the API.","commonSituations":"Version skew (client written for a newer Glances), typos in option names, or querying an option that only exists in a different run mode (e.g. server vs standalone).","solutions":["GET /api/4/args and pick an exact key from the returned JSON","Check glances --help on the serving instance for valid option names","Align client and server versions if the option exists only in a newer release"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"args = requests.get(f'{base}/api/4/args').json()\nif item not in args:\n    raise KeyError(f'{item} not in args; valid: {sorted(args)}')","typeGuard":"def valid_arg(name: str) -> bool:\n    return name in requests.get(f'{base}/api/4/args').json()","tryCatchPattern":"try:\n    val = requests.get(f'{base}/api/4/args/{item}').json()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400:\n        # unknown arg name\n        ...","preventionTips":["Fetch /api/4/args once and use its keys as the source of truth","Check glances --help on the server for available options","Version-lock client and server"],"tags":["glances","rest-api","cli-args","http-400","validation"],"backgroundTag":"http-400-bad-request","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}