{"record":{"id":"f4da0b3f7d428bda","repo":"apache/flink","slug":"given-configuration-directory-is-null-cannot-load","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/ConfigurationFileMigrationUtils.java","lineNumber":63,"sourceCode":"     * This file is only used to help users migrate their legacy configuration files to the new\n     * configuration file `config.yaml` starting from Flink 2.0.\n     */\n    @VisibleForTesting public static final String LEGACY_FLINK_CONF_FILENAME = \"flink-conf.yaml\";\n\n    /**\n     * Migrates the legacy Flink configuration from the specified directory to a standard YAML\n     * format representation.\n     *\n     * <p>This method loads the legacy configuration file named {@code flink-conf.yaml} from the\n     * specified directory. If the file is found, it converts the legacy format into a standard\n     * {@link Configuration} object in YAML format.\n     *\n     * @param configDir the directory where the legacy configuration file is located\n     * @return a {@link Configuration} object in standard YAML format\n     */\n    public static Configuration migrateLegacyToStandardYamlConfig(final String configDir) {\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        Map<String, String> configuration;\n        File yamlConfigFile = new File(confDirFile, LEGACY_FLINK_CONF_FILENAME);\n        if (!yamlConfigFile.exists()) {\n            throw new IllegalConfigurationException(","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/ConfigurationFileMigrationUtils.java#L45-L81","documentation":"ConfigurationFileMigrationUtils.migrateLegacyToStandardYamlConfig(configDir) loads the legacy flink-conf.yaml-style config from a directory. The first guard rejects a null directory argument with IllegalArgumentException, because there is nothing to search. This is a fail-fast precondition check in the legacy-config migration path (used when Flink migrates old config layouts to the standard YAML representation).","triggerScenarios":"Calling migrateLegacyToStandardYamlConfig(null) directly; an internal caller passing a config directory environment variable (FLINK_CONF_DIR) that resolved to null because it was never set and the caller did not default it.","commonSituations":"Custom launch scripts or tests invoking config loading without setting FLINK_CONF_DIR; wrapping Flink's config utilities in tooling that passes an unset variable.","solutions":["Set FLINK_CONF_DIR (or pass an explicit non-null conf/ directory path) before invoking config loading.","Default the argument in your launcher: resolveConfigDir() != null ? dir : DEFAULT_CONF_DIR.","Add a null check in your own caller and fail with a clear message naming the missing env var."],"exampleFix":"// before\nConfiguration conf = ConfigurationFileMigrationUtils.migrateLegacyToStandardYamlConfig(System.getenv(\"FLINK_CONF_DIR\"));\n\n// after\nString dir = System.getenv(\"FLINK_CONF_DIR\");\nif (dir == null) throw new IllegalStateException(\"FLINK_CONF_DIR is not set\");\nConfiguration conf = ConfigurationFileMigrationUtils.migrateLegacyToStandardYamlConfig(dir);","handlingStrategy":"validation","validationCode":"String dir = System.getenv(\"FLINK_CONF_DIR\");\nif (dir == null) {\n    throw new IllegalStateException(\"FLINK_CONF_DIR not set; refusing to load configuration\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve and check the config dir before calling config-loading utilities.","Provide a sensible default conf/ path in launch scripts."],"tags":["configuration","null-argument","startup","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}