{"record":{"id":"7cf49a8b5cf55e7f","repo":"apache/flink","slug":"file-path-cannot-be-null","errorCode":null,"errorMessage":"File path cannot be null.","messagePattern":"File path cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java","lineNumber":255,"sourceCode":"    // --------------------------------------------------------------------------------------------\n    //  Getters/setters for the configurable parameters\n    // --------------------------------------------------------------------------------------------\n\n    /**\n     * Returns the paths of all files to be read by the FileInputFormat.\n     *\n     * @return The list of all paths to read.\n     */\n    public Path[] getFilePaths() {\n        if (this.filePaths == null) {\n            return new Path[0];\n        }\n        return this.filePaths;\n    }\n\n    public void setFilePath(String filePath) {\n        if (filePath == null) {\n            throw new IllegalArgumentException(\"File path cannot be null.\");\n        }\n\n        // TODO The job-submission web interface passes empty args (and thus empty\n        // paths) to compute the preview graph. The following is a workaround for\n        // this situation and we should fix this.\n\n        // comment (Stephan Ewen) this should be no longer relevant with the current Java/Scala\n        // APIs.\n        if (filePath.isEmpty()) {\n            setFilePath(new Path());\n            return;\n        }\n\n        try {\n            this.setFilePath(new Path(filePath));\n        } catch (RuntimeException rex) {\n            throw new RuntimeException(\n                    \"Could not create a valid URI from the given file path name: \"","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java#L237-L273","documentation":"FileInputFormat.setFilePath(String) rejects a null path immediately with IllegalArgumentException. An empty string is tolerated (treated as a placeholder Path, a legacy workaround for the job-submission preview graph), but null is not, because the format must resolve a concrete filesystem location.","triggerScenarios":"Calling format.setFilePath((String) null); passing a variable that was never assigned; reading a path from configuration that returned null and forwarding it directly.","commonSituations":"Building an input format programmatically from a config map where the path key is missing; copy-paste where the path variable name is misspelled/unset; refactoring that leaves a null path reference.","solutions":["Provide a non-null file path string, e.g. format.setFilePath(\"hdfs:///data/input\").","Validate the path is non-null before calling setFilePath.","Use the Path overload (setFilePath(Path)) if you already have a Path object."],"exampleFix":"// before\nString path = config.get(\"inputPath\"); // null\nformat.setFilePath(path); // throws\n\n// after\nString path = checkNotNull(config.get(\"inputPath\"), \"inputPath must be set\");\nformat.setFilePath(path);","handlingStrategy":"validation","validationCode":"String path = Preconditions.checkNotNull(configuredPath, \"file path must be set\");\nformat.setFilePath(path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Preconditions.checkNotNull on config-derived paths.","Fail the job early at submission if the path is missing.","Prefer the typed Path overload when you already have a Path."],"tags":["input-format","file-path","validation","illegal-argument"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}