{"record":{"id":"eb6e8b76e86229b1","repo":"apache/beam","slug":"unable-to-read-data-hadoopformatio","errorCode":null,"errorMessage":"Unable to read data: {}","messagePattern":"Unable to read data: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java","lineNumber":983,"sourceCode":"      @Override\n      public KV<K, V> getCurrent() {\n        K key;\n        V value;\n        try {\n          // Transform key if translation function is provided.\n          key =\n              transformKeyOrValue(\n                  recordReader.getCurrentKey(), keyTranslationFunction, keyCoder, skipKeyClone);\n          // Transform value if translation function is provided.\n          value =\n              transformKeyOrValue(\n                  recordReader.getCurrentValue(),\n                  valueTranslationFunction,\n                  valueCoder,\n                  skipValueClone);\n        } catch (IOException | InterruptedException e) {\n          LOG.error(\"Unable to read data: \", e);\n          throw new IllegalStateException(\"Unable to read data: \" + \"{}\", e);\n        }\n        return KV.of(key, value);\n      }\n\n      /** Returns the serialized output of transformed key or value object. */\n      @SuppressWarnings(\"unchecked\")\n      private <T, T3> T3 transformKeyOrValue(\n          T input,\n          @Nullable SimpleFunction<T, T3> simpleFunction,\n          Coder<T3> coder,\n          boolean skipClone)\n          throws CoderException, ClassCastException {\n        T3 output;\n        if (null != simpleFunction) {\n          output = simpleFunction.apply(input);\n        } else {\n          output = (T3) input;\n        }","sourceCodeStart":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java#L965-L1001","documentation":"HadoopInputFormatReader.getCurrent() calls RecordReader.getCurrentKey()/getCurrentValue() and applies the translation functions; an IOException or InterruptedException during that is logged and rethrown as this IllegalStateException, since the reader is now in an unrecoverable state for the current record.","triggerScenarios":"RecordReader.getCurrentKey()/getCurrentValue() throws (e.g., corrupt file block, decoder failure) or is interrupted while the runner calls getCurrent() after advance() returned true.","commonSituations":"Corrupt HDFS blocks or truncated input files; key/value translation function throwing internally; thread interruption mid-read.","solutions":["Validate/repair the input data (run hdfs fsck, exclude corrupt files)","Wrap translation functions to catch their own exceptions and map bad records instead of failing","Check Hadoop logs for the chained cause to identify the underlying I/O problem"],"exampleFix":"// before\nnew ValueTranslateFn<MyIn, MyOut>() { public MyOut translate(MyIn v) { return riskyParse(v); } }\n// after\nnew ValueTranslateFn<MyIn, MyOut>() { public MyOut translate(MyIn v) { try { return riskyParse(v); } catch (Exception e) { return null; /* or default */ } } }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  KV<K,V> kv = reader.getCurrent();\n} catch (IllegalStateException e) {\n  LOG.error(\"Failed to fetch current record\", e);\n  metrics.counter(\"bad-records\").inc();\n  // skip or fail per pipeline policy\n}","preventionTips":["Run hdfs fsck / verify input integrity before pipeline launch","Make translation functions defensive — catch and map bad values instead of throwing","Inspect the chained cause (IOException vs InterruptedException) to choose skip vs fail"],"tags":["hadoop","recordreader","illegal-state","current"],"backgroundTag":"file-read-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}