apache/hadoop · error · IllegalArgumentException
Credential has not been provided in configuration
Error message
Credential has not been provided in configuration
What it means
ConfCredentialBasedAccessTokenProvider.getCredential throws IllegalArgumentException when the credential field is null. Normally setConf(conf) already loads it via Utils.notNull from the dfs.webhdfs.oauth2.credential key (which would throw 'No value for dfs.webhdfs.oauth2.credential found in conf file.' at ConfCredentialBasedAccessTokenProvider.java:50), so this residual guard fires only when getCredential() is called on a provider that was never configured — i.e., setConf was bypassed or failed before assignment.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/oauth2/ConfCredentialBasedAccessTokenProvider.java:56
private String credential;
public ConfCredentialBasedAccessTokenProvider() {
}
public ConfCredentialBasedAccessTokenProvider(Timer timer) {
super(timer);
}
@Override
public void setConf(Configuration conf) {
super.setConf(conf);
credential = notNull(conf, OAUTH_CREDENTIAL_KEY);
}
@Override
public String getCredential() {
if(credential == null) {
throw new IllegalArgumentException("Credential has not been " +
"provided in configuration");
}
return credential;
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Always call provider.setConf(conf) with a Configuration containing dfs.webhdfs.oauth2.credential before any getCredential() use
- Prefer constructing providers through the configuration chain (dfs.webhdfs.oauth2.access.token.provider) so WebHdfsFileSystem initializes them
- In tests, set the credential key on the test Configuration before setConf
Example fix
// before
ConfCredentialBasedAccessTokenProvider p = new ConfCredentialBasedAccessTokenProvider(timer);
String cred = p.getCredential(); // credential == null -> throws
// after
Configuration conf = new Configuration();
conf.set("dfs.webhdfs.oauth2.credential", "my-credential");
p.setConf(conf);
String cred = p.getCredential(); Defensive patterns
Strategy: validation
Validate before calling
Configuration conf = new Configuration();
conf.set("dfs.webhdfs.oauth2.credential", credential);
provider.setConf(conf); // loads credential via Utils.notNull
assert provider.getCredential() != null; // now guaranteed Prevention
- Always setConf() a fully-populated Configuration before using an AccessTokenProvider
- Let WebHdfsFileSystem create providers via dfs.webhdfs.oauth2.access.token.provider instead of manual construction
- In tests, set the credential key before initialization
When it happens
Trigger: Constructing ConfCredentialBasedAccessTokenProvider and calling getCredential() without a prior setConf(); or custom wiring/injection that instantiates the provider but skips configuration (common in unit tests or custom FileSystem factories).
Common situations: Unit tests instantiating token providers directly; dependency-injected providers whose configure step silently failed; calling getCredential() from a different thread before initialization completed; copying example code that shows only the getter usage.
Related errors
- Unable to load OAuth2 connection factory.
- No value for {key} found in conf file.
- Unsupported block buffer "{}"
- The trash feature(fs.obs.trash.enable) is enabled, but the c
- Failed to initialize %s
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c2eb58afc3734a25.
Report an issue: GitHub.