{"id":"bd02f0753f0c1615","repo":"apache/kafka","slug":"the-provider-has-not-been-configured-yet-bd02f0","errorCode":null,"errorMessage":"The provider has not been configured yet.","messagePattern":"The provider has not been configured yet\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java","lineNumber":64,"sourceCode":"\n    public static final String ALLOWED_PATHS_CONFIG = \"allowed.paths\";\n    public static final String ALLOWED_PATHS_DOC = \"A comma separated list of paths that this config provider is \" +\n            \"allowed to access. If not set, all paths are allowed.\";\n    private volatile AllowedPaths allowedPaths;\n\n    public void configure(Map<String, ?> configs) {\n        allowedPaths = new AllowedPaths((String) configs.getOrDefault(ALLOWED_PATHS_CONFIG, null));\n    }\n\n    /**\n     * Retrieves the data at the given Properties file.\n     *\n     * @param path the file where the data resides\n     * @return the configuration data\n     */\n    public ConfigData get(String path) {\n        if (allowedPaths == null) {\n            throw new IllegalStateException(\"The provider has not been configured yet.\");\n        }\n\n        Map<String, String> data = new HashMap<>();\n        if (path == null || path.isEmpty()) {\n            return new ConfigData(data);\n        }\n\n        Path filePath = allowedPaths.parseUntrustedPath(path);\n        if (filePath == null) {\n            log.warn(\"The path {} is not allowed to be accessed\", path);\n            return new ConfigData(data);\n        }\n\n        try (Reader reader = reader(filePath)) {\n            Properties properties = new Properties();\n            properties.load(reader);\n            Enumeration<Object> keys = properties.keys();\n            while (keys.hasMoreElements()) {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java#L46-L82","documentation":"Thrown as IllegalStateException (not ConfigException) by FileConfigProvider.get(path) when the volatile allowedPaths field is null, meaning configure(Map) was never invoked. Like DirectoryConfigProvider, FileConfigProvider requires configure() to initialise AllowedPaths before get(); the standard ConfigTransformer lifecycle calls configure() once per provider, so a null allowedPaths indicates the lifecycle was bypassed.","triggerScenarios":"Calling FileConfigProvider.get(path) before provider.configure(configs). Common in unit tests or custom code that instantiates FileConfigProvider directly and skips configure().","commonSituations":"Manually constructing FileConfigProvider in application code or a test and forgetting configure({}). Reusing a closed provider instance. A custom integration that wires providers outside Kafka's ConfigTransformer / Herder.","solutions":["Call provider.configure(configs) before any get(); configs may be Map.of() when allowed.paths is unused.","Obtain FileConfigProvider through ConfigTransformer so configure() runs automatically.","In tests, call fileConfigProvider.configure(Map.of()) in @BeforeEach."],"exampleFix":"// before\nFileConfigProvider p = new FileConfigProvider();\nConfigData d = p.get(\"/etc/secrets.properties\");\n\n// after\nFileConfigProvider p = new FileConfigProvider();\np.configure(Map.of());\nConfigData d = p.get(\"/etc/secrets.properties\");","handlingStrategy":"validation","validationCode":"// Enforce configure() before get():\nFileConfigProvider provider = new FileConfigProvider();\nprovider.configure(configs); // MUST run first; sets the volatile AllowedPaths\n// Only now:\nConfigData data = provider.get(path);","typeGuard":null,"tryCatchPattern":"try {\n    provider.get(path);\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not been configured yet\")) {\n        provider.configure(configs);\n        provider.get(path); // single retry after explicit configure\n    } else { throw e; }\n}","preventionTips":["Always call configure() immediately after constructing FileConfigProvider; do not defer or skip.","Use a factory method that returns an already-configured provider so the unconfigured state is unreachable.","If integrating via Kafka's ConfigTransformer, rely on its built-in configure step rather than instantiating providers directly."],"tags":["config-provider","initialization","file-config-provider","lifecycle"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}