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

  1. Call provider.configure(configs) (configs may be empty Map or contain allowed.paths) before the first get() call.
  2. If using Kafka's ConfigTransformer, obtain providers through it so configure() is invoked automatically.
  3. 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

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


AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03). Data as JSON: /data/errors/8102b7040570fd04.json. Report an issue: GitHub.