{"record":{"id":"d11546ed32c57b98","repo":"apache/hadoop","slug":"gzip-header-crc-failure","errorCode":null,"errorMessage":"gzip header CRC failure","messagePattern":"gzip header CRC failure","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java","lineNumber":347,"sourceCode":"          return;  // exit early:  used up entire buffer\n        }\n      }\n      state = GzipStateLabel.HEADER_CRC;\n    }\n\n    if (userBufLen <= 0) {\n      return;\n    }\n\n    if (state == GzipStateLabel.HEADER_CRC) {\n      if (hasHeaderCRC) {\n        assert (localBufOff < 2);\n        int n = Math.min(userBufLen, 2-localBufOff);\n        copyBytesToLocal(n);\n        if (localBufOff >= 2) {\n          long headerCRC = readUShortLE(localBuf, 0);\n          if (headerCRC != (crc.getValue() & 0xffff)) {\n            throw new IOException(\"gzip header CRC failure\");\n          }\n          localBufOff = 0;\n          crc.reset();\n          state = GzipStateLabel.DEFLATE_STREAM;\n        }\n      } else {\n        crc.reset();   // will reuse for CRC-32 of uncompressed data\n        state = GzipStateLabel.DEFLATE_STREAM;  // switching to Inflater now\n      }\n    }\n  }\n\n  /**\n   * Parse the gzip trailer (assuming we're in the appropriate state).\n   * In order to deal with degenerate cases (e.g., user buffer is one byte\n   * long), we copy trailer bytes (all 8 of 'em) to a local buffer.</p>\n   *\n   * See http://www.ietf.org/rfc/rfc1952.txt for the gzip spec.","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java#L329-L365","documentation":"Error \"gzip header CRC failure\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java:347 when the library encounters an invalid state.","commonSituations":"Occurs when the gzip header CRC check fails, indicating corrupted or truncated input. Validate input integrity and re-read or re-download the file; handle the CRC exception as a corrupt-data signal.","solutions":["The gzip header is corrupt; re-read or re-transfer the file from a trusted source.","Verify the writer completed and flushed the gzip stream before the reader opened it."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}