apache/flink · error · IllegalArgumentException
Could not parse value for key '%s'.
Error message
Could not parse value for key '%s'.
What it means
Configuration.getOptional(option) converts the raw value to the option's type; if conversion throws, Flink reports a parse error. This variant (without the value echoed) is used when the option key is considered SENSITIVE — GlobalConfiguration.isSensitive(key, additionalSensitiveKeys) matched (e.g. keys containing 'password', 'secret', 'token', or listed in security.additional-sensitive-keys) — so the raw value is deliberately omitted from the message to avoid leaking credentials into logs.
Source
Thrown at flink-core/src/main/java/org/apache/flink/configuration/Configuration.java:378
*/
@PublicEvolving
public <T> T get(ConfigOption<T> configOption, T overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
@Override
public <T> Optional<T> getOptional(ConfigOption<T> option) {
Optional<Object> rawValue = getRawValueFromOption(option);
Class<?> clazz = option.getClazz();
try {
if (option.isList()) {
return rawValue.map(v -> ConfigurationUtils.convertToList(v, clazz));
} else {
return rawValue.map(v -> ConfigurationUtils.convertValue(v, clazz));
}
} catch (Exception e) {
throw new IllegalArgumentException(
GlobalConfiguration.isSensitive(
option.key(),
this.get(SecurityOptions.ADDITIONAL_SENSITIVE_KEYS))
? String.format("Could not parse value for key '%s'.", option.key())
: String.format(
"Could not parse value '%s' for key '%s'.",
rawValue.map(Object::toString).orElse(""), option.key()),
e);
}
}
@Override
public <T> Configuration set(ConfigOption<T> option, T value) {
final boolean canBePrefixMap = canBePrefixMap(option);
setValueInternal(option.key(), value, canBePrefixMap);
return this;
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Fix the value's syntax: durations as '10 s'/'60 s'/ISO-8601, memory as '1 gb', numbers plain; check the option's declared type.
- Check for stray quotes/whitespace introduced by YAML formatting around the sensitive value.
- If you genuinely need the value echoed for debugging, temporarily read it via conf.getString on a non-sensitive alias or check the file directly — never commit the fix with the secret printed.
- For custom options, avoid sensitive-sounding key names unless the value really is secret.
Example fix
# before metrics.reporter.prom.token.duration: 10 secondz # unparseable duration # after metrics.reporter.prom.token.duration: 10 s
Defensive patterns
Strategy: validation
Validate before calling
// Validate syntax before getOptional for duration-like options:
static boolean validDuration(String v) {
return v == null || v.matches("(\\d+(\\.\\d+)?\\s*(ns|ms|s|min|min|h|d)\\s*)+|P.*");
} Prevention
- Lint config files for unit syntax ('10 s' not '10sec') in CI.
- Remember sensitive keys mask the value in errors — check the config file directly when debugging.
- Never log the resolved value of sensitive keys yourself.
When it happens
Trigger: A sensitive option (password/secret/token-like key) whose configured value cannot be parsed into the option's type: a malformed duration ('10 secondz'), malformed memory size ('1gbx'), non-numeric string for an int option, or bad list syntax.
Common situations: Typing a wrong unit in 'security.ssl.keystore-password'-adjacent duration/size options; copy-pasting a value with trailing whitespace or quotes into flink-conf.yaml for a typed sensitive option; a custom option named like a secret but declared with a non-string type.
Related errors
- Could not parse value '%s' for key '%s'.
- Could not register security manager due to no permission to
- Not allowed configuration change(s) were detected:\n - {erro
- Artifact fetching from raw HTTP endpoints are disabled. Set
- Configuration cannot evaluate value %s as a byte[] value
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/36993e1b72a48ecd.
Report an issue: GitHub.