{"record":{"id":"d59aff670dd6b30a","repo":"prestodb/presto","slug":"invalid-footer-length-s","errorCode":null,"errorMessage":"Invalid footer length %s","messagePattern":"Invalid footer length (.+?)","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/cache/StorageOrcFileTailSource.java","lineNumber":114,"sourceCode":"        }\n\n        // verify this is a supported version\n        checkOrcVersion(orcDataSource, postScript.getVersion());\n        validateWrite(writeValidation, orcDataSource, validation -> validation.getVersion().equals(postScript.getVersion()), \"Unexpected version\");\n\n        int bufferSize = toIntExact(postScript.getCompressionBlockSize());\n\n        // check compression codec is supported\n        CompressionKind compressionKind = postScript.getCompression();\n        validateWrite(writeValidation, orcDataSource, validation -> validation.getCompression() == compressionKind, \"Unexpected compression\");\n\n        PostScript.HiveWriterVersion hiveWriterVersion = postScript.getHiveWriterVersion();\n\n        int footerSize = toIntExact(postScript.getFooterLength());\n        int metadataSize = toIntExact(postScript.getMetadataLength());\n\n        if (footerSize < 0) {\n            throw new OrcCorruptionException(orcDataSource.getId(), \"Invalid footer length %s\", footerSize);\n        }\n        if (metadataSize < 0) {\n            throw new OrcCorruptionException(orcDataSource.getId(), \"Invalid metadata length %s\", metadataSize);\n        }\n\n        // read DWRF stripe cache only if this feature is enabled and it has meaningful data\n        boolean readDwrfStripeCache = dwrfStripeCacheEnabled\n                && postScript.getDwrfStripeCacheLength().isPresent()\n                && postScript.getDwrfStripeCacheMode().isPresent()\n                && postScript.getDwrfStripeCacheMode().get() != DwrfStripeCacheMode.NONE;\n        int dwrfStripeCacheSize = 0;\n        if (readDwrfStripeCache) {\n            dwrfStripeCacheSize = postScript.getDwrfStripeCacheLength().getAsInt();\n            checkSizes(orcDataSource, metadataSize, dwrfStripeCacheSize);\n        }\n\n        // check if extra bytes need to be read\n        Slice completeFooterSlice;","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/cache/StorageOrcFileTailSource.java#L96-L132","documentation":"After decoding the PostScript, the library extracts footerLength and metadataLength. A negative footer length is structurally impossible in a valid ORC file, so OrcCorruptionException is thrown. This means the postscript bytes decoded to an implausible value — the file tail is corrupt or the writer was incompatible.","triggerScenarios":"getOrcFileTail decodes a PostScript whose getFooterLength() is negative (value parsed from corrupt tail bytes).","commonSituations":"Bit-flip corruption on storage, truncated-then-partially-overwritten files, files written by non-Hive ORC variants with unsupported postscript fields.","solutions":["Validate the file with orc-tools (java -jar orc-tools-*-uber.jar meta file.orc) to pinpoint the corruption.","Re-generate or re-copy the file; postscript/footer corruption is not repairable in place.","Check storage layer (disk/HDFS) for silent corruption; enable checksum verification.","Compare the writer version/implementation that produced the file against supported versions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { tail = source.getOrcFileTail(ds, reader, validation, false, time); }\ncatch (OrcCorruptionException e) { failQueryWithFileLocation(ds.getId(), e); }","preventionTips":["Enable storage checksums to detect silent corruption","Keep writer and reader ORC versions compatible","Regularly validate archival files with orc-tools"],"tags":["orc","corrupt-file","footer"],"backgroundTag":"orc-file-corruption","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}