{"record":{"id":"9e7ab4196d2d261a","repo":"apache/flink","slug":"the-file-path-is-null","errorCode":null,"errorMessage":"The file path is null.","messagePattern":"The file path is null\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/FileOutputFormat.java","lineNumber":206,"sourceCode":"            throw new IllegalArgumentException(\n                    \"TaskNumber: \" + taskNumber + \", numTasks: \" + numTasks);\n        }\n\n        if (LOG.isDebugEnabled()) {\n            LOG.debug(\n                    \"Opening stream for output (\"\n                            + (taskNumber + 1)\n                            + \"/\"\n                            + numTasks\n                            + \"). WriteMode=\"\n                            + writeMode\n                            + \", OutputDirectoryMode=\"\n                            + outputDirectoryMode);\n        }\n\n        Path p = this.outputFilePath;\n        if (p == null) {\n            throw new IOException(\"The file path is null.\");\n        }\n\n        final FileSystem fs = p.getFileSystem();\n\n        // if this is a local file system, we need to initialize the local output directory here\n        if (!fs.isDistributedFS()) {\n\n            if (numTasks == 1 && outputDirectoryMode == OutputDirectoryMode.PARONLY) {\n                // output should go to a single file\n\n                // prepare local output path. checks for write mode and removes existing files in\n                // case of OVERWRITE mode\n                if (!fs.initOutPathLocalFS(p, writeMode, false)) {\n                    // output preparation failed! Cancel task.\n                    throw new IOException(\n                            \"Output path '\"\n                                    + p.toString()\n                                    + \"' could not be initialized. Canceling task...\");","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/FileOutputFormat.java#L188-L224","documentation":"Thrown by FileOutputFormat.open as an IOException when the outputFilePath field is null at the point the open method tries to resolve the filesystem. This is a secondary guard beyond configure(); it fires if the path was somehow cleared between configure() and open(), or if a subclass bypasses configure().","triggerScenarios":"outputFilePath set to null after configure() but before open(); a subclass overriding configure without keeping the path; running open without the runtime invoking configure (custom invocation order).","commonSituations":"Subclass that resets state between phases; a serialized format whose transient path handling is broken; manual open() invocation in tests without configure().","solutions":["Do not mutate outputFilePath after configure(); keep the lifecycle intact (configure → open).","In tests, call configure(...) before open(...) and ensure a path was set.","If subclassing, do not null out outputFilePath."],"exampleFix":"// before: test calls open without configure / path\nformat.open(ctx);\n\n// after\nformat.setOutputFilePath(new Path(tempDir.toUri()));\nformat.configure(new Configuration());\nformat.open(ctx);","handlingStrategy":"validation","validationCode":"// In tests: configure + set path before open\nformat.setOutputFilePath(new Path(tempDir.toUri()));\nformat.configure(new Configuration());\nformat.open(ctx);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the configure → open lifecycle intact; do not null the path between them.","Call configure(...) before open(...) in manual/test invocations.","Subclasses must not clear outputFilePath."],"tags":["flink","file-output","null-check","lifecycle","testing"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}