{"record":{"id":"ea8e110fa3383286","repo":"nicolargo/glances","slug":"cannot-get-config-section-section-str-e","errorCode":null,"errorMessage":"Cannot get config section {section} ({str(e)})","messagePattern":"Cannot get config section (.+?) \\((.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":1317,"sourceCode":"            return GlancesJSONResponse(args_json)\n\n    def _api_config_section(self, section: str):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of the Glances configuration section\n        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\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        return GlancesJSONResponse(ret_section)\n\n    def _api_config_section_item(self, section: str, item: str):\n        \"\"\"Glances API RESTful implementation.\n\n        Return the JSON representation of the Glances configuration section/item\n        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]","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L1299-L1335","documentation":"Raised as HTTP 404 by GET /api/4/config/{section} when fetching the value of a section that passed the membership check still fails. Because the membership check already ran on the same dict, hitting this branch in practice means an exotic failure during dict access (custom dict subclass, concurrent config mutation between the check and the read) rather than a normal missing key.","triggerScenarios":"GET /api/4/config/{section} where config_dict[section] raises — e.g. the config dict was replaced/reloaded concurrently, or a custom config implementation overrides __getitem__ and raises.","commonSituations":"Extremely rare; seen with plugins that swap self.config at runtime or with patched Glances versions using non-standard config classes.","solutions":["Retry the request once — a transient race with config reload usually clears","Inspect the parenthesized str(e) to identify the real exception type from the custom config class","If you maintain a custom config class, make __getitem__ behave like a plain dict's"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    r = requests.get(f'{base}/api/4/config/{section}')\n    if r.status_code != 404 or 'Cannot get config section' not in r.text:\n        break\n    time.sleep(0.2)","preventionTips":["Avoid swapping self.config while serving requests","Treat this 404 as transient; retry once before failing"],"tags":["glances","rest-api","config","http-404","race-condition"],"backgroundTag":"http-404-not-found","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}