{"record":{"id":"2bd9b479f47a0027","repo":"apache/flink","slug":"file-path-must-not-be-null","errorCode":null,"errorMessage":"File path must not be null.","messagePattern":"File path must not be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java","lineNumber":285,"sourceCode":"        }\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: \"\n                            + rex.getMessage());\n        }\n    }\n\n    /**\n     * Sets a single path of a file to be read.\n     *\n     * @param filePath The path of the file to read.\n     */\n    public void setFilePath(Path filePath) {\n        if (filePath == null) {\n            throw new IllegalArgumentException(\"File path must not be null.\");\n        }\n\n        setFilePaths(filePath);\n    }\n\n    /**\n     * Sets multiple paths of files to be read.\n     *\n     * @param filePaths The paths of the files to read.\n     */\n    public void setFilePaths(String... filePaths) {\n        Path[] paths = new Path[filePaths.length];\n        for (int i = 0; i < paths.length; i++) {\n            paths[i] = new Path(filePaths[i]);\n        }\n        setFilePaths(paths);\n    }\n","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java#L267-L303","documentation":"The Path overload of FileInputFormat.setFilePath delegates to setFilePaths(filePath) after a null check. A null Path cannot be resolved to a filesystem location, so it is rejected with IllegalArgumentException. This guards the typed entry point that the String overload (error 312) feeds into.","triggerScenarios":"Calling format.setFilePath((Path) null); passing a Path variable that was constructed from null parts or never assigned.","commonSituations":"Building the path conditionally and forgetting the branch that leaves it null; chaining new Path(null); refactoring that drops the assignment.","solutions":["Construct and pass a non-null Path, e.g. format.setFilePath(new Path(uri)).","Validate with Preconditions.checkNotNull(path, ...) before calling setFilePath.","Prefer the String overload when you only have a string, so the URI-error message is clearer."],"exampleFix":"// before\nPath p = maybeResolvePath(); // null\nformat.setFilePath(p); // throws\n\n// after\nPath p = Preconditions.checkNotNull(maybeResolvePath(), \"path must be resolved\");\nformat.setFilePath(p);","handlingStrategy":"validation","validationCode":"Path p = Preconditions.checkNotNull(resolvedPath, \"path must be resolved\");\nformat.setFilePath(p);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve paths eagerly and null-check before setFilePath.","Use Preconditions.checkNotNull with a descriptive message.","Prefer the String overload for friendlier URI error messages."],"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"}