apache/flink · error · IllegalArgumentException
The input {} contains an empty argument
Error message
The input {} contains an empty argument What it means
ParameterTool.fromArgs walks the args array expecting '--key value' pairs; after stripping leading dashes an argument that is empty (the empty string, or a bare '-'/'--') yields an empty key and this IllegalArgumentException printing the whole args array. It is a fail-fast check that the CLI contract (non-empty flag names) is met.
Source
Thrown at flink-core/src/main/java/org/apache/flink/util/ParameterTool.java:70
/**
* Returns {@link ParameterTool} for the given arguments. The arguments are keys followed by
* values. Keys have to start with '-' or '--'
*
* <p><strong>Example arguments:</strong> --key1 value1 --key2 value2 -key3 value3
*
* @param args Input array arguments
* @return A {@link ParameterTool}
*/
public static ParameterTool fromArgs(String[] args) {
final Map<String, String> map = CollectionUtil.newHashMapWithExpectedSize(args.length / 2);
int i = 0;
while (i < args.length) {
final String key = Utils.getKeyFromArgs(args, i);
if (key.isEmpty()) {
throw new IllegalArgumentException(
"The input " + Arrays.toString(args) + " contains an empty argument");
}
i += 1; // try to find the value
if (i >= args.length) {
map.put(key, AbstractParameterTool.NO_VALUE_KEY);
} else if (NumberUtils.isNumber(args[i])) {
map.put(key, args[i]);
i += 1;
} else if (args[i].startsWith("--") || args[i].startsWith("-")) {
// the argument cannot be a negative number because we checked earlier
// -> the next argument is a parameter name
map.put(key, AbstractParameterTool.NO_VALUE_KEY);
} else {
map.put(key, args[i]);
i += 1;
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Inspect the printed args array to find the empty element and remove it.
- Fix the launcher: filter empty strings before calling Flink, e.g. Arrays.stream(args).filter(s -> !s.isEmpty()).
- In shell scripts, quote variables and guard optional flags so empty values are not passed at all.
Example fix
// before ParameterTool params = ParameterTool.fromArgs(args); // args contains "" // after String[] cleaned = Arrays.stream(args).filter(s -> !s.isEmpty()).toArray(String[]::new); ParameterTool params = ParameterTool.fromArgs(cleaned);
Defensive patterns
Strategy: validation
Validate before calling
String[] cleaned = Arrays.stream(args).filter(s -> s != null && !s.isEmpty() && !s.equals("--") && !s.equals("-")).toArray(String[]::new);
ParameterTool params = ParameterTool.fromArgs(cleaned); Prevention
- Filter empty argv elements where the process is launched.
- Quote shell variables; build arg lists without conditional empty entries.
When it happens
Trigger: args containing "" (e.g. from a shell quoting bug), a lone "--" or "-" used as a separator, or an option name reduced to nothing after '--' stripping.
Common situations: Shell scripts passing "$EMPTY_VAR" unquoted-expanded; argument lists built by joining with stray empty elements; users inserting '--' expecting an end-of-options marker.
Related errors
- Value for config option %s must be one of %s (was %s)
- Segment size must be a power of 2!
- {directory} is not a directory but a regular file
- Invalid port configuration. Port must be between 0and 65535,
- Invalid port configuration. Port must be between 0and 65535,
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/ea0aca4ff903c1ef.
Report an issue: GitHub.