{"record":{"id":"2fdadc046591fdb2","repo":"prestodb/presto","slug":"druid-segment-load-error-2fdadc","errorCode":"DRUID_SEGMENT_LOAD_ERROR","errorMessage":"Zip doesn't contain file: %s","messagePattern":"Zip doesn't contain file: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-druid/src/main/java/com/facebook/presto/druid/segment/ZipIndexFileSource.java","lineNumber":67,"sourceCode":"\n    private ZipFileData zipData;\n\n    public ZipIndexFileSource(DataInputSource dataInputSource)\n    {\n        this.dataInputSource = requireNonNull(dataInputSource, \"dataInputSource is null\");\n        zipData = readCentralDirectory();\n    }\n\n    /**\n     * Reads file inside a zip archive\n     */\n    @Override\n    public byte[] readFile(String fileName)\n            throws IOException\n    {\n        ZipFileEntry entry = zipData.getEntry(fileName);\n        if (entry == null) {\n            throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, format(\"Zip doesn't contain file: %s\", fileName));\n        }\n        byte[] fileData = new byte[(int) entry.getSize()];\n        readFully(entry, 0, fileData, 0, fileData.length);\n        return fileData;\n    }\n\n    @Override\n    public final void readFile(String fileName, long position, byte[] buffer)\n            throws IOException\n    {\n        ZipFileEntry entry = zipData.getEntry(fileName);\n        if (entry == null) {\n            throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, format(\"Zip doesn't contain file: %s\", fileName));\n        }\n        readFully(entry, position, buffer, 0, buffer.length);\n    }\n\n    private void readFully(ZipFileEntry entry, long position, byte[] buffer, int bufferOffset, int bufferLength)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-druid/src/main/java/com/facebook/presto/druid/segment/ZipIndexFileSource.java#L49-L85","documentation":"Thrown when readFile(name) is asked for a file that does not exist inside the segment zip archive. ZipIndexFileSource reads Druid segments stored as zips and looks up entries in the central directory (zipData); a missing entry means the requested file isn't in the archive.","triggerScenarios":"readFile(fileName) finds no ZipFileEntry for fileName — requesting meta.json/__metadata/a column file that the zip lacks.","commonSituations":"Querying a column absent from the segment zip, stale segment cache pointing to an older zip layout, wrong segment file supplied, Druid version differences in internal file names.","solutions":["Verify the requested file/column exists (list zip entries: unzip -l segment.zip)","Refresh the segment cache or re-download the segment zip","Align connector version with the Druid segment format version","Fix the column/table mapping to match files actually in the zip"],"exampleFix":"// before\nbyte[] meta = indexFileSource.readFile(\"__metadata\");\n// after\nif (zipHasEntry(indexFileSource, \"__metadata\")) {\n    byte[] meta = indexFileSource.readFile(\"__metadata\");\n}","handlingStrategy":"validation","validationCode":"// caller-side pre-check\nZipFile zip = new ZipFile(segmentZipPath);\nboolean present = zip.stream().anyMatch(e -> e.getName().equals(\"__metadata\"));\nif (!present) { throw new PrestoException(NOT_FOUND, \"Entry missing from segment zip\"); }","typeGuard":"function hasEntry(entries, name) { return entries != null && entries.some(e => e.name === name); }","tryCatchPattern":"try {\n    byte[] data = indexFileSource.readFile(fileName);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"DRUID_SEGMENT_LOAD_ERROR\") && e.getMessage().contains(\"doesn't contain file\")) {\n        // treat as missing column / stale segment: re-fetch\n    } else { throw e; }\n}","preventionTips":["List zip entries (unzip -l) once per segment and build a whitelist of valid file names","Invalidate caches when segments are replaced","Match connector expectations to the Druid segment format version","Check that the table mapping only references columns present in the segment"],"tags":["druid","zip","segment","missing-file"],"backgroundTag":"file-not-found-in-archive","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"}