{"record":{"id":"588ee1a65f4a3d09","repo":"elastic/elasticsearch","slug":"cannot-retrieve-setting","errorCode":null,"errorMessage":"cannot retrieve setting [{}]","messagePattern":"cannot retrieve setting \\[(.+?)\\]","errorType":"exception","errorClass":"SslConfigException","httpStatus":null,"severity":"error","filePath":"libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java","lineNumber":458,"sourceCode":"            }\n        }\n    }\n\n    private String stringSetting(String key) {\n        return resolveSetting(key, Function.identity(), null);\n    }\n\n    private <V> V resolveSetting(String key, Function<String, V> parser, V defaultValue) {\n        try {\n            String setting = getSettingAsString(expandSettingKey(key));\n            if (setting == null || setting.isEmpty()) {\n                return defaultValue;\n            }\n            return parser.apply(setting);\n        } catch (RuntimeException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new SslConfigException(\"cannot retrieve setting [\" + settingPrefix + key + \"]\", e);\n        }\n    }\n\n    private char[] resolveSecureSetting(String key, char[] defaultValue) {\n        try {\n            char[] setting = getSecureSetting(expandSettingKey(key));\n            if (setting == null || setting.length == 0) {\n                return defaultValue;\n            }\n            return setting;\n        } catch (RuntimeException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new SslConfigException(\"cannot retrieve secure setting [\" + settingPrefix + key + \"]\", e);\n        }\n\n    }\n","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java#L440-L476","documentation":"resolveSetting wraps any checked (non-Runtime) Exception thrown by getSettingAsString while reading a single string value. RuntimeExceptions are rethrown unchanged. The error names the full setting key (prefix + key) and attaches the cause.","triggerScenarios":"A custom SslConfigurationLoader subclass's getSettingAsString implementation throws a checked Exception (e.g. IOException, InterruptedException) for the named setting — for instance when the backing store is a remote secrets manager that fails to respond.","commonSituations":"Custom Source-of-settings integration (Vault, AWS Secrets Manager) that declares checked exceptions; misbehaving Settings implementation in a plugin; interrupted thread during settings read.","solutions":["Inspect the attached cause for the real failure (IO error, timeout, auth).","Make getSettingAsString robust — catch transient failures inside it or declare only RuntimeException-derived types.","Verify the underlying settings source is reachable and authorised before reload."],"exampleFix":"// before: subclass throws IOException\npublic String getSettingAsString(String key) throws IOException {\n    return vault.read(key);\n}\n// after: wrap into a RuntimeException so resolveSetting rethrows cleanly\npublic String getSettingAsString(String key) {\n    try { return vault.read(key); }\n    catch (IOException e) { throw new RuntimeException(e); }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SslConfiguration cfg = loader.load(basePath);\n} catch (SslConfigException e) {\n    if (e.getMessage().startsWith(\"cannot retrieve setting\")) {\n        Throwable cause = e.getCause();\n        log.error(\"Settings source failure for {}: {}\", e.getMessage(), cause.toString());\n    }\n    throw e;\n}","preventionTips":["In custom SslConfigurationLoader subclasses, catch checked exceptions inside getSettingAsString and wrap them in a RuntimeException with a clear message.","Keep the settings source reachable and authenticated before triggering a reload.","Log the cause chain — the wrapped exception carries the real reason."],"tags":["ssl","config","settings","integration"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}