{"record":{"id":"7262aa3f652d7bd8","repo":"apache/iceberg","slug":"decoding-datum-failed","errorCode":null,"errorMessage":"Decoding datum failed","messagePattern":"Decoding datum failed","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/data/avro/RawDecoder.java","lineNumber":72,"sourceCode":"  }\n\n  private final DatumReader<D> reader;\n\n  /**\n   * Creates a new {@link MessageDecoder} that constructs datum instances using the {@code reader}.\n   */\n  private RawDecoder(DatumReader<D> reader) {\n    this.reader = reader;\n  }\n\n  @Override\n  public D decode(InputStream stream, D reuse) {\n    BinaryDecoder decoder = DecoderFactory.get().directBinaryDecoder(stream, DECODER.get());\n    DECODER.set(decoder);\n    try {\n      return reader.read(reuse, decoder);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Decoding datum failed\", e);\n    }\n  }\n}\n","sourceCodeStart":54,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/data/avro/RawDecoder.java#L54-L76","documentation":"RawDecoder.decode wraps the InputStream in an Avro BinaryDecoder and delegates to the ValueReader. If the underlying read throws IOException, it is rethrown as UncheckedIOException(\"Decoding datum failed\") with the original as cause. It means the encoded datum could not be read — usually corrupt or truncated data.","triggerScenarios":"decode(stream, reuse) where the binary payload is truncated mid-record or the stream fails during value reading (closed stream, corrupt bytes, wrong schema version producing misaligned reads).","commonSituations":"Truncated files from incomplete writes; reading with a mismatched reader schema causing misparse; concurrent stream closure; corrupt network transfer.","solutions":["Inspect the cause IOException to determine truncation vs corruption.","Regenerate the data file/stream — the payload is likely truncated or corrupt.","Verify reader schema matches the schema used to encode the data.","Wrap decode in try-catch for UncheckedIOException and treat failed datums as poison records."],"exampleFix":"// before\nD d = rawDecoder.decode(stream, reuse); // UncheckedIOException on truncated data\n// after\ntry {\n  D d = rawDecoder.decode(stream, reuse);\n} catch (UncheckedIOException e) {\n  LOG.error(\"Datum decode failed\", e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { return rawDecoder.decode(stream, reuse); } catch (UncheckedIOException e) { LOG.error(\"Decoding datum failed\", e.getCause()); throw new CorruptDataException(e.getCause()); }","preventionTips":["Ensure writers complete and flush before readers start","Verify reader schema matches the encoding schema","Checksum data files after transfer to detect truncation"],"tags":["avro","decoder","corrupt-data","io"],"backgroundTag":"json-decode-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}