apache/flink · error · RuntimeException
No data for required key '{key}'
Error message
No data for required key '{key}' What it means
Thrown by AbstractParameterTool.getRequired(String key) when the key has no value. ParameterTool is Flink's utility for passing program arguments (parsed with ParameterTool.fromArgs), and getRequired enforces mandatory parameters by throwing an unchecked RuntimeException at access time.
Source
Thrown at flink-core/src/main/java/org/apache/flink/util/AbstractParameterTool.java:79
protected abstract int getNumberOfParameters();
/**
* Returns the String value for the given key. If the key does not exist it will return null.
*/
protected abstract String get(String key);
/** Check if value is set. */
public abstract boolean has(String value);
/**
* Returns the String value for the given key. If the key does not exist it will throw a {@link
* RuntimeException}.
*/
public String getRequired(String key) {
addToDefaults(key, null);
String value = get(key);
if (value == null) {
throw new RuntimeException("No data for required key '" + key + "'");
}
return value;
}
/**
* Returns the String value for the given key. If the key does not exist it will return the
* given default value.
*/
public String get(String key, String defaultValue) {
addToDefaults(key, defaultValue);
String value = get(key);
if (value == null) {
return defaultValue;
} else {
return value;
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Check the actual command line/properties for the missing or misspelled key and pass it
- Use has(key) or get(key, defaultValue) when the parameter is optional instead of required
- Call getRequired for all mandatory keys once at startup with a clear usage message, so failures happen before the job is submitted
Example fix
// before
String input = params.getRequired("input");
// after
if (!params.has("input")) {
throw new IllegalArgumentException("Missing required argument '--input <path>'");
}
String input = params.getRequired("input"); Defensive patterns
Strategy: validation
Validate before calling
if (!params.has("input")) {
throw new IllegalArgumentException("Missing required parameter '--input'");
}
String input = params.getRequired("input"); Try / catch
Optionally wrap getRequired calls in a try/catch (RuntimeException e) at program start to print usage text and exit non-zero instead of a stack trace.
Prevention
- Validate all required keys once in main() before execute() so the job fails at submission, not mid-run
- Prefer getRequired over get for mandatory params so absence is loud, and prefer get(key, default) for optional ones
When it happens
Trigger: Calling parameterTool.getRequired("input") when 'input' was never passed via --input ..., when the key has a typo (e.g. --inptu), or when the tool was built from a properties file that lacks the key.
Common situations: Missing or misspelled command-line arguments in a Flink job submission; environment-specific config files that omit a key that production supplies; a key present in one environment profile but not another.
Related errors
- Given configuration directory is null, cannot load configura
- The given configuration directory name '{}' ({}) does not de
- The Flink config file '{}' ({}) does not exist.
- Error parsing YAML configuration.
- Exception when trying to initialize plugin system.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/794d26ef192f845e.
Report an issue: GitHub.