{"record":{"id":"48a7d3c1cbd171aa","repo":"prestodb/presto","slug":"stripe-encryption-keys-are-missing-but-file-is-en","errorCode":null,"errorMessage":"Stripe encryption keys are missing, but file is encrypted","messagePattern":"Stripe encryption keys are missing, but file is encrypted","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"critical","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcReader.java","lineNumber":295,"sourceCode":"            DwrfStripeCache cache = dwrfStripeCacheData.buildDwrfStripeCache(footer.getStripes(), footer.getDwrfStripeCacheOffsets().get());\n            dwrfStripeCache = Optional.of(cache);\n        }\n\n        requireNonNull(stripeMetadataSourceFactory, \"stripeMetadataSourceFactory is null\");\n        this.stripeMetadataSource = requireNonNull(stripeMetadataSourceFactory.create(dwrfStripeCache), \"stripeMetadataSource is null\");\n    }\n\n    @VisibleForTesting\n    public static void validateEncryption(Footer footer, OrcDataSourceId dataSourceId)\n    {\n        if (!footer.getEncryption().isPresent()) {\n            return;\n        }\n        DwrfEncryption dwrfEncryption = footer.getEncryption().get();\n        int encryptionGroupSize = dwrfEncryption.getEncryptionGroups().size();\n        List<StripeInformation> stripes = footer.getStripes();\n        if (!stripes.isEmpty() && encryptionGroupSize > 0 && stripes.get(0).getKeyMetadata().isEmpty()) {\n            throw new OrcCorruptionException(dataSourceId, \"Stripe encryption keys are missing, but file is encrypted\");\n        }\n        for (StripeInformation stripe : stripes) {\n            if (!stripe.getKeyMetadata().isEmpty() && stripe.getKeyMetadata().size() != encryptionGroupSize) {\n                throw new OrcCorruptionException(\n                        dataSourceId,\n                        \"Number of stripe encryption keys did not match number of encryption groups.  Expected %s, but found %s\",\n                        encryptionGroupSize,\n                        stripe.getKeyMetadata().size());\n            }\n        }\n    }\n\n    public List<String> getColumnNames()\n    {\n        return footer.getTypes().get(0).getFieldNames();\n    }\n\n    public List<OrcType> getTypes()","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcReader.java#L277-L313","documentation":"validateEncryption checks DWRF per-stripe key metadata. If the file declares encryption groups but stripes exist whose key metadata is empty, the encrypted file is missing the keys needed for decryption, so OrcCorruptionException is thrown.","triggerScenarios":"OrcReader on a DWRF file with footer.getEncryption() present, non-empty stripes, encryptionGroupSize > 0, and the first stripe's getKeyMetadata() empty.","commonSituations":"Partially written or corrupted encrypted files, writers that omitted key metadata, files stripped/rewritten by tools that dropped encryption metadata.","solutions":["Obtain an intact copy of the encrypted file from the writer","Ensure the writer was configured with the encryption keys/key providers correctly","Re-write the file without encryption if key material is unrecoverable","Verify the reading library version matches the DWRF encryption feature version that wrote the file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (footer.getEncryption().isPresent() && !stripes.isEmpty()) {\n    check(stripes.get(0).getKeyMetadata().isPresent(), \"missing stripe key metadata\");\n}","typeGuard":null,"tryCatchPattern":"try { reader = new OrcReader(...); }\ncatch (OrcCorruptionException e) {\n    if (e.getMessage().contains(\"encryption keys are missing\")) { /* fetch intact copy */ }\n}","preventionTips":["Keep encrypted files' key metadata intact (do not strip footers)","Use matching writer/reader versions for DWRF encryption","Checksum encrypted files at rest"],"tags":["orc","dwrf","encryption","key-metadata","corruption"],"backgroundTag":"missing-encryption-key","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"}