{"record":{"id":"146acfb0df31ce8b","repo":"apache/hadoop","slug":"output-directory-not-set","errorCode":null,"errorMessage":"Output directory not set.","messagePattern":"Output directory not set\\.","errorType":"validation","errorClass":"InvalidJobConfException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/FileOutputFormat.java","lineNumber":156,"sourceCode":"            conf.getClassByName(name).asSubclass(CompressionCodec.class);\n      } catch (ClassNotFoundException e) {\n        throw new IllegalArgumentException(\"Compression codec \" + name + \n                                           \" was not found.\", e);\n      }\n    }\n    return codecClass;\n  }\n  \n  public abstract RecordWriter<K, V> \n     getRecordWriter(TaskAttemptContext job\n                     ) throws IOException, InterruptedException;\n\n  public void checkOutputSpecs(JobContext job\n                               ) throws FileAlreadyExistsException, IOException{\n    // Ensure that the output directory is set and not already there\n    Path outDir = getOutputPath(job);\n    if (outDir == null) {\n      throw new InvalidJobConfException(\"Output directory not set.\");\n    }\n\n    // get delegation token for outDir's file system\n    TokenCache.obtainTokensForNamenodes(job.getCredentials(),\n        new Path[] { outDir }, job.getConfiguration());\n\n    if (outDir.getFileSystem(job.getConfiguration()).exists(outDir)) {\n      throw new FileAlreadyExistsException(\"Output directory \" + outDir + \n                                           \" already exists\");\n    }\n  }\n\n  /**\n   * Set the {@link Path} of the output directory for the map-reduce job.\n   *\n   * @param job The job to modify\n   * @param outputDir the {@link Path} of the output directory for \n   * the map-reduce job.","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/FileOutputFormat.java#L138-L174","documentation":"Thrown as InvalidJobConfException (an IOException subclass) from FileOutputFormat.checkOutputSpecs (FileOutputFormat.java:156) when getOutputPath(job) returns null — i.e. mapreduce.output.fileoutputformat.outputdir is unset. checkOutputSpecs runs on the job client at submission, so the job fails before any mapper starts: FileOutputFormat refuses to run without a destination.","triggerScenarios":"Submitting a job whose OutputFormat derives from FileOutputFormat while FileOutputFormat.setOutputPath(job, ...) was never called — e.g. only MultipleOutputs channels were configured, the setOutputPath line was dropped in a refactor, or the OutputFormat was switched from NullOutputFormat/DBOutputFormat to a FileOutputFormat without adding the path.","commonSituations":"Jobs that write exclusively through MultipleOutputs and forget the (still mandatory) default output path; pipelines where the output path is computed from an argument that came back null/empty; tutorial code adapted and the setOutputPath call removed.","solutions":["Call FileOutputFormat.setOutputPath(job, new Path(\"...\")) before job.waitForCompletion()","If the job truly needs no default file output, set an OutputFormat without this check: job.setOutputFormatClass(NullOutputFormat.class) (then configure MultipleOutputs separately)","If output goes through MultipleOutputs only, still set a default output path or use LazyOutputFormat to avoid empty part files"],"exampleFix":"// before: FileOutputFormat-derived OutputFormat, no destination\njob.setOutputFormatClass(TextOutputFormat.class);\n\n// after: explicit output path\njob.setOutputFormatClass(TextOutputFormat.class);\nFileOutputFormat.setOutputPath(job, new Path(args[1]));","handlingStrategy":"validation","validationCode":"// before submit\nif (FileOutputFormat.getOutputPath(job) == null) {\n  throw new IllegalArgumentException(\"Configure output path before submission\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair setOutputPath with a FileOutputFormat-derived OutputFormat","If no default file output is wanted, switch to NullOutputFormat","Assert required job config in the driver's validate() step"],"tags":["hadoop","mapreduce","job-configuration","output-path","job-submission"],"backgroundTag":"missing-job-output-path","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}