{"record":{"id":"a670f4f1de812273","repo":"apache/flink","slug":"output-file-path-may-not-be-null","errorCode":null,"errorMessage":"Output file path may not be null.","messagePattern":"Output file path may not be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/FileOutputFormat.java","lineNumber":130,"sourceCode":"    private transient Path actualFilePath;\n\n    /**\n     * Flag indicating whether this format actually created a file, which should be removed on\n     * cleanup.\n     */\n    private transient boolean fileCreated;\n\n    // --------------------------------------------------------------------------------------------\n\n    public FileOutputFormat() {}\n\n    public FileOutputFormat(Path outputPath) {\n        this.outputFilePath = outputPath;\n    }\n\n    public void setOutputFilePath(Path path) {\n        if (path == null) {\n            throw new IllegalArgumentException(\"Output file path may not be null.\");\n        }\n\n        this.outputFilePath = path;\n    }\n\n    public Path getOutputFilePath() {\n        return this.outputFilePath;\n    }\n\n    public void setWriteMode(WriteMode mode) {\n        if (mode == null) {\n            throw new NullPointerException();\n        }\n\n        this.writeMode = mode;\n    }\n\n    public WriteMode getWriteMode() {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/FileOutputFormat.java#L112-L148","documentation":"Thrown by FileOutputFormat.setOutputFilePath(Path) when the argument is null. The output path is a mandatory sink attribute; a null value would later cause NPEs during path resolution, so it is rejected eagerly at the setter.","triggerScenarios":"Calling setOutputFilePath(null); passing a Path variable that was never assigned; a config-driven path that resolves to null (e.g., missing config key) before being set on the format.","commonSituations":"Building a FileOutputFormat dynamically where the path comes from a config/parameter that wasn't provided; refactoring that removes the assignment; tests that construct the format without a path then call the setter with a null placeholder.","solutions":["Pass a non-null Path constructed from a known base URI and filename.","If the path is config-driven, validate the config value is present before constructing the Path.","Prefer the FileOutputFormat(Path) constructor which sets the path in one step."],"exampleFix":"// before\nFileOutputFormat out = new FileOutputFormat();\nout.setOutputFilePath(pathFromConfig); // pathFromConfig is null\n\n// after\nPath outPath = new Path(requireNonNull(pathFromConfig, \"output path config missing\"));\nFileOutputFormat out = new FileOutputFormat(outPath);","handlingStrategy":"validation","validationCode":"Path out = Objects.requireNonNull(pathFromConfig, \"output path config must be present\");\nFileOutputFormat format = new FileOutputFormat(out);","typeGuard":"// Ensure the path is non-null before calling the setter\nstatic Path requireOutputPath(String uri) {\n    if (uri == null || uri.isEmpty()) {\n        throw new IllegalArgumentException(\"output path uri is required\");\n    }\n    return new Path(uri);\n}","tryCatchPattern":null,"preventionTips":["Prefer the FileOutputFormat(Path) constructor to set the path atomically.","Treat output path as a required config field with a non-null validator.","Unit test sink assembly asserting getOutputFilePath() != null."],"tags":["flink","file-output","null-check","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}