apache/flink · error · IllegalArgumentException
Configuration cannot evaluate value %s as a byte[] value
Error message
Configuration cannot evaluate value %s as a byte[] value
What it means
Configuration.getBytes(key, default) is the legacy typed getter: it looks up the raw stored value and, unless the stored object's class is exactly byte[], throws IllegalArgumentException 'Configuration cannot evaluate value %s as a byte[] value'. Unlike modern ConfigOption getters it does no string coercion — the value must have been put as a byte array via setBytes/setValue(byte[]) or parsed as TYPE_BYTES.
Source
Thrown at flink-core/src/main/java/org/apache/flink/configuration/Configuration.java:156
}
/**
* Returns the value associated with the given key as a byte array.
*
* @param key The key pointing to the associated value.
* @param defaultValue The default value which is returned in case there is no value associated
* with the given key.
* @return the (default) value associated with the given key.
*/
@Internal
public byte[] getBytes(String key, byte[] defaultValue) {
return getRawValue(key)
.map(
o -> {
if (o.getClass().equals(byte[].class)) {
return (byte[]) o;
} else {
throw new IllegalArgumentException(
String.format(
"Configuration cannot evaluate value %s as a byte[] value",
o));
}
})
.orElse(defaultValue);
}
/**
* Adds the given byte array to the configuration object. If key is <code>null</code> then
* nothing is added.
*
* @param key The key under which the bytes are added.
* @param bytes The bytes to be added.
*/
@Internal
public void setBytes(String key, byte[] bytes) {
setValueInternal(key, bytes);View on GitHub (pinned to 2f3c205e92)
Solutions
- Store the value as byte[] (conf.setBytes(key, bytes)) instead of a string, if you must use getBytes.
- Migrate to the ConfigOption API: define ConfigOption<byte[]> or parse explicitly: BaseEncoding.base64().decode(conf.getString(key)).
- If the value may legitimately be a string encoding of bytes, read it with getString and decode it yourself.
Example fix
// before
byte[] secret = conf.getBytes("security.secret", null); // key came from YAML as String -> throws
// after
byte[] secret = java.util.Base64.getDecoder().decode(conf.getString("security.secret", "")); Defensive patterns
Strategy: type-guard
Validate before calling
Object raw = conf.getRawValue(key).orElse(null);
if (raw != null && !raw.getClass().equals(byte[].class)) {
throw new IllegalArgumentException("Key '" + key + "' is " + raw.getClass().getSimpleName() + ", not byte[]");
} Type guard
boolean isByteValue(Configuration conf, String key) {
return conf.getRawValue(key).map(o -> o.getClass().equals(byte[].class)).orElse(true);
} Prevention
- Do not use the legacy getBytes on YAML-loaded configuration — values there are Strings.
- Standardize on the ConfigOption API for new code.
- Encode binary data as base64 strings if it must round-trip through config files.
When it happens
Trigger: Calling getBytes on a key whose value was stored as String, Integer, Boolean, or any non-byte[] type (e.g. read from flink-conf.yaml where everything parses to a String); mixing the old String-keyed API with YAML-loaded values.
Common situations: Legacy code paths calling conf.getBytes("some.key", null) on keys defined in the YAML config file; internal utilities expecting byte[] set programmatically but the key was overridden in configuration files.
Related errors
- Unrecognized type. This method is deprecated and might not w
- Unrecognized type: %s. This method is deprecated and might n
- Value for config option %s must be one of %s (was %s)
- Could not parse value for key '%s'.
- Could not parse value '%s' for key '%s'.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/6d0d42745a46ec85.
Report an issue: GitHub.