apache/dubbo · error · IllegalStateException
Try to get '${key}' failed, maybe because this key doesn't m
Error message
Try to get '${key}' failed, maybe because this key doesn't map to a Boolean object What it means
Thrown by Configuration.getBoolean(key, Boolean defaultValue) when the value for key exists but cannot be converted to a Boolean. convert(Boolean.class, key, defaultValue) throws an Exception (e.g. the value is neither true nor false), which is caught and re-thrown as IllegalStateException. This is a type mismatch on a boolean-valued property, distinct from error 101 which is about missing keys.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/config/Configuration.java:105
default boolean getBoolean(String key) {
Boolean b = this.getBoolean(key, null);
if (b != null) {
return b;
} else {
throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object");
}
}
default boolean getBoolean(String key, boolean defaultValue) {
return this.getBoolean(key, toBooleanObject(defaultValue));
}
default Boolean getBoolean(String key, Boolean defaultValue) {
try {
return convert(Boolean.class, key, defaultValue);
} catch (Exception e) {
throw new IllegalStateException(
"Try to get " + '\'' + key + "' failed, maybe because this key doesn't map to a Boolean object", e);
}
}
/**
* Gets a property from the configuration. This is the most basic get
* method for retrieving values of properties. In a typical implementation
* of the {@code Configuration} interface the other get methods (that
* return specific data types) will internally make use of this method. On
* this level variable substitution is not yet performed. The returned
* object is an internal representation of the property value for the passed
* in key. It is owned by the {@code Configuration} object. So a caller
* should not modify this object. It cannot be guaranteed that this object
* will stay constant over time (i.e. further update operations on the
* configuration may change its internal state).
*
* @param key property to retrieve
* @return the value to which this configuration maps the specified key, orView on GitHub (pinned to 3a3043227f)
Solutions
- Change the configured value to a literal true or false (case-insensitive).
- If the value must be a truthy string, read it with getString(key) and map it yourself: "yes"/"1"/"on" -> true.
- Check the original Exception cause chained in the IllegalStateException for the exact value that failed conversion.
Example fix
// before (in application.yml)
dubbo:
consumer:
check: yes
// after
dubbo:
consumer:
check: true Defensive patterns
Strategy: validation
Validate before calling
String raw = configuration.getString(key);
if (raw != null && !raw.equalsIgnoreCase("true") && !raw.equalsIgnoreCase("false")) {
// value is present but not boolean; sanitize or reject
return defaultValue;
} Try / catch
try {
return configuration.getBoolean(key, defaultValue);
} catch (IllegalStateException e) {
logger.warn("Non-boolean value for key {}, using default", key);
return defaultValue;
} Prevention
- Only use true/false (case-insensitive) for boolean properties.
- If environment provides yes/no or 1/0, map them to true/false before Dubbo reads them.
- Add a config validation step in CI to catch malformed boolean values.
When it happens
Trigger: Calling configuration.getBoolean(key, defaultValue) where the resolved property value is a non-boolean string such as "yes", "1", "on", or "maybe". Dubbo's Boolean converter only accepts "true"/"false" (case-insensitive).
Common situations: Setting boolean Dubbo properties using shell-style truthy values (yes/no, on/off, 1/0) instead of Java boolean literals. Common when migrating from other frameworks or when environment variables from infrastructure tools use non-Java-boolean conventions.
Related errors
- '${key}' doesn't map to a Integer object
- '${key}' doesn't map to an existing object
- load config failed, id: <id>, type:<cls.getSimpleName()>
- already exists bean with same name and type, name=${name}, t
- expected single matching bean but found ${size} candidates f
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/75cd8b6d6d50958e.
Report an issue: GitHub.