apache/kafka · error · ConfigException
Path is not supported for EnvVarConfigProvider, invalid valu
Error message
Path is not supported for EnvVarConfigProvider, invalid value '{path}' What it means
Thrown as ConfigException by EnvVarConfigProvider.get(path, keys) when a non-null, non-empty path is supplied. The provider sources values from System.getenv() only; the path parameter is explicitly documented as unused, so any value is treated as a misconfiguration and rejected. Keys are matched against the configured allowlist pattern instead.
Source
Thrown at clients/src/main/java/org/apache/kafka/common/config/provider/EnvVarConfigProvider.java:100
* @param path unused
* @return returns environment variables as configuration
*/
@Override
public ConfigData get(String path) {
return get(path, null);
}
/**
* @param path path, not used for environment variables
* @param keys the keys whose values will be retrieved.
* @return the configuration data.
*/
@Override
public ConfigData get(String path, Set<String> keys) {
if (path != null && !path.isEmpty()) {
log.error("Path is not supported for EnvVarConfigProvider, invalid value '{}'", path);
throw new ConfigException("Path is not supported for EnvVarConfigProvider, invalid value '" + path + "'");
}
if (keys == null) {
return new ConfigData(filteredEnvVarMap);
}
Map<String, String> filteredData = new HashMap<>(filteredEnvVarMap);
filteredData.keySet().retainAll(keys);
return new ConfigData(filteredData);
}
private Map<String, String> getEnvVars() {
try {
return System.getenv();
} catch (Exception e) {
log.error("Could not read environment variables", e);
throw new ConfigException("Could not read environment variables");View on GitHub (pinned to c31c9215e1)
Solutions
- Remove the path segment from the substitution: use ${env:VAR_NAME} (or ${env::VAR_NAME}) instead of ${env:/some/path:VAR_NAME}.
- Confirm the provider name maps to EnvVarConfigProvider and switch to FileConfigProvider/DirectoryConfigProvider if you actually need filesystem lookups.
- If calling get() directly, pass null or empty string as the path argument.
Example fix
# before
config.providers=env
value=${env:/etc/secrets:API_KEY}
# after
config.providers=env
value=${env:API_KEY} Defensive patterns
Strategy: validation
Validate before calling
// EnvVarConfigProvider ignores path; never pass a meaningful value. String safePath = (path == null || path.isEmpty()) ? null : null; // i.e. force null/empty before calling get(): ConfigData data = envProvider.get(null);
Try / catch
try {
envProvider.get(path);
} catch (ConfigException e) {
if (e.getMessage() != null
&& e.getMessage().contains("Path is not supported for EnvVarConfigProvider")) {
envProvider.get(null); // retry with no path
} else { throw e; }
} Prevention
- EnvVarConfigProvider.get(path) does not use path — always pass null or empty string.
- If a generic ConfigProvider pipeline supplies path, special-case EnvVarConfigProvider to coerce path to null.
- Document/abstract this in a shared helper so callers cannot accidentally feed a path to an env-var-only provider.
When it happens
Trigger: Externalized config substitution referencing the env provider with a path segment, e.g. ${env:/path/to:KEY} or ${env:someDir:VAR}, which calls EnvVarConfigProvider.get("/path/to", keys) with a non-empty path. Any direct call get(nonEmptyPath, keys) on the env provider.
Common situations: Confusing EnvVarConfigProvider with FileConfigProvider/DirectoryConfigProvider and supplying a path placeholder in the config substitution syntax. Copying a ${file:/etc/secrets:...} pattern and forgetting to drop the path when switching to ${env:...}.
Related errors
- Could not read environment variables
- Could not load config provider class or one of its dependenc
- Path normalisedPath is not absolute
- Path normalisedPath does not exist
- Path normalisedPath could not be resolved
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/b41fa0b933cb4ca4.json.
Report an issue: GitHub.