apache/flink · error · RuntimeException

No data for required key '{}'

Error message

No data for required key '{}'

What it means

MultipleParameterTool is a ParameterTool variant that supports repeated keys (multi-values). getMultiParameterRequired(key) fetches all values for a key and throws RuntimeException when the key is absent from the parsed data — it marks the parameter as mandatory. The key string is included in the message.

Source

Thrown at flink-core/src/main/java/org/apache/flink/util/MultipleParameterTool.java:184

    /**
     * Returns the Collection of String values for the given key. If the key does not exist it will
     * return null.
     */
    public Collection<String> getMultiParameter(String key) {
        addToDefaults(key, null);
        unrequestedParameters.remove(key);
        return data.getOrDefault(key, null);
    }

    /**
     * Returns the Collection of String values for the given key. If the key does not exist it will
     * throw a {@link RuntimeException}.
     */
    public Collection<String> getMultiParameterRequired(String key) {
        addToDefaults(key, null);
        Collection<String> value = getMultiParameter(key);
        if (value == null) {
            throw new RuntimeException("No data for required key '" + key + "'");
        }
        return value;
    }

    // ------------------------- Export to different targets -------------------------

    /**
     * Return MultiMap of all the parameters processed by {@link MultipleParameterTool}.
     *
     * @return MultiMap of the {@link MultipleParameterTool}. Key is String and Value is a
     *     Collection of String.
     */
    public Map<String, Collection<String>> toMultiMap() {
        return data;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Supply the missing key on the command line (e.g. --key value1 --key value2 for multi-parameters).
  2. Check exact spelling/case of the key against what the program expects — ParameterTool matching is exact-string based.
  3. If the parameter is optional in your flow, use getMultiParameter(key) and handle null instead of the Required variant.
  4. Add usage/help text listing required keys and validate required args up front with a friendly message.

Example fix

// before
Collection<String> inputs = params.getMultiParameterRequired("input");

# run: flink run Job.jar --ouput /tmp/out   # 'input' missing -> RuntimeException

// after: validate first
if (params.getMultiParameter("input") == null) {
    System.err.println("Usage: Job --input <path> [--input <path>...]");
    return 1;
}
Defensive patterns

Strategy: validation

Validate before calling

Collection<String> values = params.getMultiParameter(key);
if (values == null) {
    throw new IllegalArgumentException("Missing required parameter --" + key + ". Usage: ...");
}
return values;

Prevention

When it happens

Trigger: Calling getMultiParameterRequired(key) on a MultipleParameterTool built from args or properties where 'key' was never supplied (or supplied with a different spelling/case).

Common situations: CLI jobs run without a required argument (e.g. --input missing); key mismatch due to typos, casing, or leading dashes ('-k' vs '--key'); parameters loaded from a properties file that omitted the key; deprecated argument names after a refactor.

Related errors


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