apache/flink · error · IllegalArgumentException

Given configuration directory is null, cannot load configura

Error message

Given configuration directory is null, cannot load configuration

What it means

Thrown by GlobalConfiguration.loadConfiguration when the configDir argument is null. This is a hard precondition check before any filesystem access is attempted, indicating the caller did not supply a configuration directory path.

Source

Thrown at flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java:126

     * @param configDir the directory which contains the configuration files
     */
    public static Configuration loadConfiguration(final String configDir) {
        return loadConfiguration(configDir, null);
    }

    /**
     * Loads the configuration files from the specified directory. If the dynamic properties
     * configuration is not null, then it is added to the loaded configuration.
     *
     * @param configDir directory to load the configuration from
     * @param dynamicProperties configuration file containing the dynamic properties. Null if none.
     * @return The configuration loaded from the given configuration directory
     */
    public static Configuration loadConfiguration(
            final String configDir, @Nullable final Configuration dynamicProperties) {

        if (configDir == null) {
            throw new IllegalArgumentException(
                    "Given configuration directory is null, cannot load configuration");
        }

        final File confDirFile = new File(configDir);
        if (!(confDirFile.exists())) {
            throw new IllegalConfigurationException(
                    "The given configuration directory name '"
                            + configDir
                            + "' ("
                            + confDirFile.getAbsolutePath()
                            + ") does not describe an existing directory.");
        }

        // get Flink yaml configuration file
        Configuration configuration;
        File yamlConfigFile = new File(confDirFile, FLINK_CONF_FILENAME);
        if (!yamlConfigFile.exists()) {
            throw new IllegalConfigurationException(

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Ensure FLINK_CONF_DIR is set to a valid directory path.
  2. Pass a non-null explicit config directory path to loadConfiguration.
  3. If using a custom entry point, resolve and validate the conf dir before calling GlobalConfiguration.

Example fix

// before
Configuration conf = GlobalConfiguration.loadConfiguration(System.getenv("MISSING_VAR"));

// after
String dir = System.getenv("FLINK_CONF_DIR");
if (dir == null) throw new IllegalStateException("FLINK_CONF_DIR not set");
Configuration conf = GlobalConfiguration.loadConfiguration(dir);
Defensive patterns

Strategy: validation

Validate before calling

String dir = configDir;
if (dir == null) throw new IllegalArgumentException("configDir is null");

Prevention

When it happens

Trigger: Calling GlobalConfiguration.loadConfiguration(null) or passing a variable that resolved to null (e.g., System.getenv("FLINK_CONF_DIR") when the env var is unset). Also triggered by frameworks that pass null when no conf dir is configured.

Common situations: FLINK_CONF_DIR environment variable not set. Running Flink client code outside the standard distribution layout. Custom launch scripts that forget to pass the conf dir.

Related errors


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