{"record":{"id":"637316ddd05b5cd6","repo":"prestodb/presto","slug":"write-validation-failed","errorCode":null,"errorMessage":"Write validation failed: ","messagePattern":"Write validation failed: ","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcReader.java","lineNumber":526,"sourceCode":"                    OrcPredicate.TRUE,\n                    hiveStorageTimeZone,\n                    NOOP_ORC_AGGREGATED_MEMORY_CONTEXT,\n                    INITIAL_BATCH_SIZE)) {\n                while (orcRecordReader.nextBatch() >= 0) {\n                    // ignored\n                }\n            }\n        }\n        catch (IOException e) {\n            throw new OrcCorruptionException(e, input.getId(), \"Validation failed\");\n        }\n    }\n\n    public static void validateWrite(Optional<OrcWriteValidation> writeValidation, OrcDataSource orcDataSource, Predicate<OrcWriteValidation> test, String messageFormat, Object... args)\n            throws OrcCorruptionException\n    {\n        if (writeValidation.isPresent() && !test.test(writeValidation.get())) {\n            throw new OrcCorruptionException(orcDataSource.getId(), \"Write validation failed: \" + messageFormat, args);\n        }\n    }\n\n    public OrcDataSource getOrcDataSource()\n    {\n        return orcDataSource;\n    }\n\n    public StripeFooter readStripeFooter(StripeInformation stripe)\n            throws IOException\n    {\n        requireNonNull(stripe, \"stripe is null\");\n\n        byte[] tailBuffer = new byte[toIntExact(stripe.getFooterLength())];\n        orcDataSource.readFully(stripe.getOffset() + stripe.getIndexLength() + stripe.getDataLength(), tailBuffer);\n        try (InputStream inputStream = new OrcInputStream(\n                orcDataSource.getId(),\n                new SharedBuffer(NOOP_ORC_LOCAL_MEMORY_CONTEXT),","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcReader.java#L508-L544","documentation":"validateWrite evaluates a Predicate against the OrcWriteValidation collected during a write. If validation is present and the predicate fails, the written file did not meet expectations and OrcCorruptionException is thrown with the caller-provided formatted message.","triggerScenarios":"Static call OrcReader.validateWrite with Optional<OrcWriteValidation> present and test.test(...) returning false — typically invoked from post-write checks comparing stripes, metadata, or checksums.","commonSituations":"Writer bugs producing fewer stripes/rows than recorded, metadata mismatches after rewrite, checksum inconsistencies detected by the validation framework.","solutions":["Read the formatted message args to see which validation predicate failed","Rewrite the ORC file with validation enabled to catch the writer bug","Compare writer version and reader validation expectations","Disable specific write validations only after identifying the root cause"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    OrcReader.validateWrite(validation, dataSource, predicate, \"stripe count mismatch\");\n}\ncatch (OrcCorruptionException e) {\n    LOG.error(\"Write validation: \" + e.getMessage(), e); // args detail the failed predicate\n}","preventionTips":["Run validateWrite on every written file in staging","Keep writer versions consistent within a pipeline","Record stripe/metadata expectations at write time"],"tags":["orc","validation","write-path"],"backgroundTag":"write-validation-failed","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"}