{"record":{"id":"192e8e3473265423","repo":"apache/hadoop","slug":"outputformat-not-set-for-filteroutputformat","errorCode":null,"errorMessage":"Outputformat not set for FilterOutputFormat","messagePattern":"Outputformat not set for FilterOutputFormat","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/lib/FilterOutputFormat.java","lineNumber":65,"sourceCode":"   * @param out the underlying OutputFormat\n   */\n  public FilterOutputFormat (OutputFormat<K,V> out) {\n    this.baseOut = out;\n  }\n\n  public RecordWriter<K, V> getRecordWriter(FileSystem ignored, JobConf job, \n      String name, Progressable progress) throws IOException {\n    return getBaseOut().getRecordWriter(ignored, job, name, progress);\n  }\n\n  public void checkOutputSpecs(FileSystem ignored, JobConf job) \n  throws IOException {\n    getBaseOut().checkOutputSpecs(ignored, job);\n  }\n  \n  private OutputFormat<K,V> getBaseOut() throws IOException {\n    if (baseOut == null) {\n      throw new IOException(\"Outputformat not set for FilterOutputFormat\");\n    }\n    return baseOut;\n  }\n\n  /**\n   * <code>FilterRecordWriter</code> is a convenience wrapper\n   * class that implements  {@link RecordWriter}.\n   */\n\n  public static class FilterRecordWriter<K,V> implements RecordWriter<K,V> {\n\n    protected RecordWriter<K,V> rawWriter = null;\n\n    public FilterRecordWriter() throws IOException {\n      rawWriter = null;\n    }\n\n    public FilterRecordWriter(RecordWriter<K,V> rawWriter)  throws IOException {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/lib/FilterOutputFormat.java#L47-L83","documentation":"FilterOutputFormat is a wrapper (template) OutputFormat that delegates getRecordWriter() and checkOutputSpecs() to an inner OutputFormat held in its protected baseOut field. getBaseOut() throws this IOException when either method is invoked and baseOut was never assigned. It means the wrapper subclass was used without configuring the delegate it is supposed to wrap.","triggerScenarios":"Writing a custom class that extends FilterOutputFormat but never assigns baseOut (or assigns it only lazily on a path not taken), then the framework calls checkOutputSpecs() or getRecordWriter() during job submission/task run. Instantiating the raw FilterOutputFormat type through configuration also hits this, since nothing sets baseOut.","commonSituations":"Copy-paste of LazyOutputFormat-like wrappers where the author forgets the baseOut = ... assignment; using a third-party OutputFormat that extends FilterOutputFormat but expects a configuration key that was never set (its lazy lookup returned null and it left baseOut null).","solutions":["In your FilterOutputFormat subclass, assign baseOut in the constructor or before first delegation (e.g. baseOut = new TextOutputFormat<>())","If you want output created only when records are written, use LazyOutputFormat.setOutputFormatClass(job, RealFormat.class) instead of hand-rolling a wrapper","If the subclass reads the delegate from a conf key, make sure that key is set before job submission","Fail fast in your subclass: throw a descriptive error in the constructor if the delegate cannot be resolved"],"exampleFix":"// before: subclass never sets the delegate\npublic class AuditOutputFormat<K,V> extends FilterOutputFormat<K,V> { }\n\n// after: set baseOut before the framework calls getRecordWriter/checkOutputSpecs\npublic class AuditOutputFormat<K,V> extends FilterOutputFormat<K,V> {\n  public AuditOutputFormat() {\n    baseOut = new TextOutputFormat<K,V>();\n  }\n}","handlingStrategy":"validation","validationCode":"// in a FilterOutputFormat subclass, fail loudly in the constructor\npublic MyFilterOutputFormat() {\n  baseOut = new TextOutputFormat<K,V>();\n  if (baseOut == null) throw new IllegalStateException(\"delegate output format required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  outputFormat.checkOutputSpecs(fs, conf);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"not set for FilterOutputFormat\")) {\n    throw new IllegalStateException(\"FilterOutputFormat subclass never assigned baseOut\", e);\n  }\n  throw e;\n}","preventionTips":["Never use FilterOutputFormat subtypes without configuring their delegate — prefer composing a concrete OutputFormat","Prefer the shipped LazyOutputFormat.setOutputFormatClass over hand-written wrappers","Unit-test checkOutputSpecs() on a locally constructed JobConf before submitting"],"tags":["hadoop","mapreduce","outputformat","filter-outputformat","delegate"],"backgroundTag":"unconfigured-delegate","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}