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

  1. Check the actual command line/properties for the missing or misspelled key and pass it
  2. Use has(key) or get(key, defaultValue) when the parameter is optional instead of required
  3. 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

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


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/794d26ef192f845e. Report an issue: GitHub.