apache/flink · error · IllegalArgumentException
argument is an empty- or whitespace-only string
Error message
argument is an empty- or whitespace-only string
What it means
MemorySize.parseBytes(String) throws IllegalArgumentException("argument is an empty- or whitespace-only string") when the input, after trimming, contains no characters. Parsing must have at least a numeric part, so blank input is rejected before any number/unit analysis.
Source
Thrown at flink-core-api/src/main/java/org/apache/flink/configuration/MemorySize.java:272
}
return parse(text);
}
/**
* Parses the given string as bytes. The supported expressions are listed under {@link
* MemorySize}.
*
* @param text The string to parse
* @return The parsed size, in bytes.
* @throws IllegalArgumentException Thrown, if the expression cannot be parsed.
*/
public static long parseBytes(String text) throws IllegalArgumentException {
Objects.requireNonNull(text, "text cannot be null");
final String trimmed = text.trim();
if (trimmed.isEmpty()) {
throw new IllegalArgumentException("argument is an empty- or whitespace-only string");
}
final int len = trimmed.length();
int pos = 0;
char current;
while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
pos++;
}
final String number = trimmed.substring(0, pos);
final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);
if (number.isEmpty()) {
throw new NumberFormatException("text does not start with a number");
}
final long value;View on GitHub (pinned to 2f3c205e92)
Solutions
- Give the property an explicit value (e.g. 64mb) or remove the key entirely so Flink's default applies
- Check `text != null && !text.trim().isEmpty()` before parsing user-supplied sizes
- Default empty inputs to a known value in your config layer instead of passing them through
Example fix
// before
long bytes = MemorySize.parseBytes(config.get("memory.size")); // key present but empty
// after
String raw = config.get("memory.size");
long bytes = (raw == null || raw.trim().isEmpty())
? DEFAULT_SIZE.getBytes()
: MemorySize.parseBytes(raw); Defensive patterns
Strategy: validation
Validate before calling
String raw = config.get(key);
if (raw == null || raw.trim().isEmpty()) {
raw = defaultSize; // e.g. "64mb"
}
long bytes = MemorySize.parseBytes(raw); Try / catch
catch (IllegalArgumentException e) { /* blank config value — report the offending key, not just the message */ } Prevention
- Omit optional memory keys entirely rather than setting them empty
- Blank-check raw config strings before parsing
- Unit-test config parsing with empty/whitespace inputs
When it happens
Trigger: MemorySize.parseBytes(""); parseBytes(" "); a config property like -Dtaskmanager.memory.network.size= (empty value) flowing into memory-size parsing.
Common situations: Optional memory settings left empty in flink-conf.yaml, env vars, or CLI -D flags; string concatenation building "1gb" producing an empty string when a variable is unset.
Related errors
- bytes must be >= 0
- text does not start with a number
- The value '{number}' cannot be re represented as 64bit numbe
- The value '{text}' cannot be re represented as 64bit number
- Memory size unit '{unit}' does not match any of the recogniz
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/aa690764eecb3b5f.
Report an issue: GitHub.