{"record":{"id":"0a20952b279f5747","repo":"nicolargo/glances","slug":"cannot-get-item-item-in-config-section-section","errorCode":null,"errorMessage":"Cannot get item {item} in config section {section} ({str(e)})","messagePattern":"Cannot get item (.+?) in config section (.+?) \\((.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":1343,"sourceCode":"        HTTP/200 if OK\n        HTTP/400 if item is not found\n        HTTP/404 if others error\n        \"\"\"\n        config_dict = self.config.as_dict() if self.args.password else self.config.as_dict_secure()\n        if section not in config_dict:\n            raise HTTPException(status.HTTP_400_BAD_REQUEST, f\"Unknown configuration item {section}\")\n\n        try:\n            # Get the RAW value of the config' dict section\n            ret_section = config_dict[section]\n        except Exception as e:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, f\"Cannot get config section {section} ({str(e)})\")\n\n        try:\n            # Get the RAW value of the config' dict item\n            ret_item = ret_section[item]\n        except Exception as e:\n            raise HTTPException(\n                status.HTTP_404_NOT_FOUND, f\"Cannot get item {item} in config section {section} ({str(e)})\"\n            )\n\n        return GlancesJSONResponse(ret_item)\n\n    # Args keys that must always be redacted (even for authenticated users)\n    _ALWAYS_REDACTED_ARGS = frozenset({'password'})\n\n    # Args keys redacted when no authentication is configured\n    # Note: keys matching the shared sensitive pattern (password, token, username...)\n    # are redacted by secure_option(), only the ones it can not express are listed here.\n    _SENSITIVE_ARGS = frozenset(\n        {\n            'password',\n            'snmp_community',\n            'snmp_user',\n            'snmp_auth',\n            'conf_file',","sourceCodeStart":1325,"sourceCodeEnd":1361,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L1325-L1361","documentation":"HTTP 404 raised by GET /api/4/config/{section}/{item} when the item key does not exist inside an existing section (or the value fetch raises). This is the normal 'item not found' signal: the section was valid, but the option name inside it is unknown or empty.","triggerScenarios":"GET /api/4/config/cpu/zzz, or any request where {section} exists but the option was never set in glances.conf (configparser omits unset options).","commonSituations":"Querying defaults that were never explicitly written into the config file, or misspelled option names.","solutions":["GET /api/4/config/{section} and inspect the returned keys to find the exact option name","Add the option explicitly to the section in glances.conf and restart glances so it appears in the dict","Remember options absent from the file are absent from the API — Glances does not merge internal defaults into this view"],"exampleFix":"# before\ncurl http://localhost:61208/api/4/config/influxdb/host\n# 404 if 'host' unset; set it first, or list keys\ncurl http://localhost:61208/api/4/config/influxdb","handlingStrategy":"validation","validationCode":"sec = requests.get(f'{base}/api/4/config/{section}').json()\nif isinstance(sec, dict) and item not in sec:\n    print('item not set in config file; using default')","typeGuard":"def has_item(section: str, item: str) -> bool:\n    sec = requests.get(f'{base}/api/4/config/{section}').json()\n    return isinstance(sec, dict) and item in sec","tryCatchPattern":"try:\n    val = requests.get(f'{base}/api/4/config/{section}/{item}').json()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 404:\n        val = DEFAULTS.get((section, item))\n    else:\n        raise","preventionTips":["Fetch the whole section once and read keys locally","Write explicit options into glances.conf if the API must expose them","Keep a client-side defaults table for unset options"],"tags":["glances","rest-api","config","http-404","key-error"],"backgroundTag":"http-404-not-found","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}