{"record":{"id":"98de04d4475c313e","repo":"apache/flink","slug":"given-configuration-directory-is-null-cannot-load-98de04","errorCode":null,"errorMessage":"Given configuration directory is null, cannot load configuration","messagePattern":"Given configuration directory is null, cannot load configuration","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java","lineNumber":126,"sourceCode":"     * @param configDir the directory which contains the configuration files\n     */\n    public static Configuration loadConfiguration(final String configDir) {\n        return loadConfiguration(configDir, null);\n    }\n\n    /**\n     * Loads the configuration files from the specified directory. If the dynamic properties\n     * configuration is not null, then it is added to the loaded configuration.\n     *\n     * @param configDir directory to load the configuration from\n     * @param dynamicProperties configuration file containing the dynamic properties. Null if none.\n     * @return The configuration loaded from the given configuration directory\n     */\n    public static Configuration loadConfiguration(\n            final String configDir, @Nullable final Configuration dynamicProperties) {\n\n        if (configDir == null) {\n            throw new IllegalArgumentException(\n                    \"Given configuration directory is null, cannot load configuration\");\n        }\n\n        final File confDirFile = new File(configDir);\n        if (!(confDirFile.exists())) {\n            throw new IllegalConfigurationException(\n                    \"The given configuration directory name '\"\n                            + configDir\n                            + \"' (\"\n                            + confDirFile.getAbsolutePath()\n                            + \") does not describe an existing directory.\");\n        }\n\n        // get Flink yaml configuration file\n        Configuration configuration;\n        File yamlConfigFile = new File(confDirFile, FLINK_CONF_FILENAME);\n        if (!yamlConfigFile.exists()) {\n            throw new IllegalConfigurationException(","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java#L108-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure FLINK_CONF_DIR is set to a valid directory path.","Pass a non-null explicit config directory path to loadConfiguration.","If using a custom entry point, resolve and validate the conf dir before calling GlobalConfiguration."],"exampleFix":"// before\nConfiguration conf = GlobalConfiguration.loadConfiguration(System.getenv(\"MISSING_VAR\"));\n\n// after\nString dir = System.getenv(\"FLINK_CONF_DIR\");\nif (dir == null) throw new IllegalStateException(\"FLINK_CONF_DIR not set\");\nConfiguration conf = GlobalConfiguration.loadConfiguration(dir);","handlingStrategy":"validation","validationCode":"String dir = configDir;\nif (dir == null) throw new IllegalArgumentException(\"configDir is null\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate configDir is non-null before calling GlobalConfiguration.loadConfiguration.","Set FLINK_CONF_DIR in launch scripts and verify it is exported.","Use a fallback default path if the env var is absent."],"tags":["configuration","startup","null-check"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}