apache/kafka · error · IllegalStateException
The provider has not been configured yet.
Error message
The provider has not been configured yet.
What it means
Thrown as IllegalStateException (not ConfigException) by DirectoryConfigProvider.get() when the volatile allowedPaths field is still null, meaning configure(Map) was never invoked. The provider requires configure() to initialise AllowedPaths (even when allowed.paths is unset) before any get() call. This is a programmer/initialisation error, not a normal runtime failure.
Source
Thrown at clients/src/main/java/org/apache/kafka/common/config/provider/DirectoryConfigProvider.java:88
}
/**
* Retrieves the data contained in the regular files named by {@code keys} in the directory given by {@code path}.
* Non-regular files (such as directories) in the given directory are silently ignored.
* @param path the directory where data files reside.
* @param keys the keys whose values will be retrieved.
* @return the configuration data.
*/
@Override
public ConfigData get(String path, Set<String> keys) {
return get(path, pathname ->
Files.isRegularFile(pathname)
&& keys.contains(pathname.getFileName().toString()));
}
private ConfigData get(String path, Predicate<Path> fileFilter) {
if (allowedPaths == null) {
throw new IllegalStateException("The provider has not been configured yet.");
}
Map<String, String> map = Map.of();
if (path != null && !path.isEmpty()) {
Path dir = allowedPaths.parseUntrustedPath(path);
if (dir == null) {
log.warn("The path {} is not allowed to be accessed", path);
return new ConfigData(map);
}
if (!Files.isDirectory(dir)) {
log.warn("The path {} is not a directory", path);
} else {
try (Stream<Path> stream = Files.list(dir)) {
map = stream
.filter(fileFilter)
.collect(Collectors.toMap(View on GitHub (pinned to c31c9215e1)
Solutions
- Call provider.configure(configs) (configs may be empty Map or contain allowed.paths) before the first get() call.
- If using Kafka's ConfigTransformer, obtain providers through it so configure() is invoked automatically.
- In tests, add directoryConfigProvider.configure(Map.of()) in @BeforeEach setup.
Example fix
// before
DirectoryConfigProvider p = new DirectoryConfigProvider();
ConfigData d = p.get("/etc/secrets");
// after
DirectoryConfigProvider p = new DirectoryConfigProvider();
p.configure(Map.of());
ConfigData d = p.get("/etc/secrets"); Defensive patterns
Strategy: validation
Validate before calling
// Enforce configure() before get(): DirectoryConfigProvider provider = new DirectoryConfigProvider(); provider.configure(configs); // MUST run first; sets the volatile AllowedPaths assert provider != null; // Only now: ConfigData data = provider.get(path);
Try / catch
try {
provider.get(path);
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().contains("not been configured yet")) {
provider.configure(configs);
provider.get(path); // single retry after explicit configure
} else { throw e; }
} Prevention
- Always pair 'new DirectoryConfigProvider()' with an immediate configure() call; never hand a raw instance to code that may call get().
- Wrap the provider in a factory/helper that performs construct+configure atomically so callers cannot skip the step.
- In tests and integration harnesses, assert that get() works post-configure so missing-configure regressions fail fast.
When it happens
Trigger: Calling DirectoryConfigProvider.get(path) or get(path, keys) before invoking configure(configs). Reproduced in unit tests that skip configure(), or in custom ConfigProvider usage that bypasses the standard ConfigTransformer lifecycle which normally calls configure() once per provider.
Common situations: Manually instantiating DirectoryConfigProvider in application code or a test and forgetting the configure({}) call. A custom integration that reuses provider instances without re-configuring them. Misusing a provider outside the ConfigTransformer / Herder wiring that normally performs configure().
Related errors
- The provider has not been configured yet.
- Could not list directory {dir}
- Could not read file {path} for property {fileName}
- NetworkClient is no longer active, state is {state}
- Client was shutdown before response was read
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/8102b7040570fd04.json.
Report an issue: GitHub.