{"record":{"id":"ff9cc0f4ed4fd6aa","repo":"nicolargo/glances","slug":"cannot-get-args-item-str-e","errorCode":null,"errorMessage":"Cannot get args item ({str(e)})","messagePattern":"Cannot get args item \\((.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":1414,"sourceCode":"            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\n        if not process_stats:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Unknown PID process {pid}\")\n\n        glances_processes.extended_process = process_stats\n","sourceCodeStart":1396,"sourceCodeEnd":1432,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L1396-L1432","documentation":"HTTP 404 raised by GET /api/4/args/{item} when building the sanitized args dict and indexing it for {item} fails. Because the preceding membership check already confirmed the attribute exists, this fires only if _sanitize_args() drops or renames the key during redaction, or throws while computing the value.","triggerScenarios":"GET /api/4/args/password-adjacent-key where the key exists in self.args but _sanitize_args() removes/redacts it so the [item] lookup raises KeyError; or sanitization itself errors.","commonSituations":"Querying credentials-related args on an unauthenticated instance — the sanitizer redacts them and the index may miss; or custom forks whose sanitizer doesn't preserve all keys.","solutions":["GET /api/4/args and read the value from the full sanitized dict instead of the item endpoint","If you need the raw value, restart glances with --password so sanitization keeps sensitive keys","Upgrade glances if the sanitizer is known to drop legit keys in your version"],"exampleFix":"# before\ncurl http://localhost:61208/api/4/args/username\n# after\ncurl http://localhost:61208/api/4/args | jq .username","handlingStrategy":"fallback","validationCode":"args = requests.get(f'{base}/api/4/args').json()\nvalue = args.get(item)  # avoids item endpoint entirely","typeGuard":"def arg_available(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 == 404:\n        val = requests.get(f'{base}/api/4/args').json().get(item)\n    else:\n        raise","preventionTips":["Prefer the collection endpoint over per-item lookups","Expect sensitive args to be redacted when unauthenticated","Run with --password when raw values are needed"],"tags":["glances","rest-api","cli-args","http-404","redaction"],"backgroundTag":"http-404-not-found","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}