{"record":{"id":"5fc5ccc8e1761f9a","repo":"prestodb/presto","slug":"druid-segment-load-error-5fc5cc","errorCode":"DRUID_SEGMENT_LOAD_ERROR","errorMessage":"File comment too long. Is %d; max %d.","messagePattern":"File comment too long\\. Is (.+?); max (.+?)\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileData.java","lineNumber":85,"sourceCode":"        comment = \"\";\n        entries = new LinkedHashMap<>();\n    }\n\n    public Charset getCharset()\n    {\n        return charset;\n    }\n\n    public String getComment()\n    {\n        return comment;\n    }\n\n    public void setComment(byte[] comment)\n    {\n        checkArgument(comment != null, \"Zip file comment could not be null\");\n        if (comment.length > 0xffff) {\n            throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, format(\"File comment too long. Is %d; max %d.\", comment.length, 0xffff));\n        }\n        this.comment = fromBytes(comment);\n    }\n\n    public void setComment(String comment)\n    {\n        setComment(getBytes(comment));\n    }\n\n    public long getCentralDirectorySize()\n    {\n        return centralDirectorySize;\n    }\n\n    public void setCentralDirectorySize(long centralDirectorySize)\n    {\n        this.centralDirectorySize = centralDirectorySize;\n        if (centralDirectorySize > 0xffffffffL) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileData.java#L67-L103","documentation":"ZipFileData.setComment enforces that a ZIP file comment is at most 0xffff (65535) bytes, because the ZIP format stores the comment length in a 2-byte field. Passing a longer comment throws DRUID_SEGMENT_LOAD_ERROR immediately.","triggerScenarios":"Calling setComment(byte[]) (or the String overload via read) with a comment longer than 65535 bytes.","commonSituations":"Programmatic zip builders that attach huge metadata blobs as the archive comment instead of a dedicated entry, or code that concatenates audit/metadata JSON into the comment.","solutions":["Truncate the comment to <= 65535 bytes before calling setComment.","Move large metadata into a dedicated zip entry (e.g., meta.json) instead of the archive comment.","Compress the metadata and store a short reference in the comment if a pointer is needed.","Assert the comment length in the producer pipeline before writing the zip."],"exampleFix":"// before\nzipFileData.setComment(largeMetadataJson);\n// after\nif (largeMetadataJson.length > 0xffff) {\n    largeMetadataJson = largeMetadataJson.substring(0, 0xffff);\n}\nzipFileData.setComment(largeMetadataJson);","handlingStrategy":"validation","validationCode":"if (comment != null && comment.length > 0xffff) {\n    comment = Arrays.copyOf(comment, 0xffff);\n}\nzipFileData.setComment(comment);","typeGuard":null,"tryCatchPattern":"try {\n    zipFileData.setComment(comment);\n} catch (PrestoException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"File comment too long\")) {\n        zipFileData.setComment(Arrays.copyOf(comment, 0xffff));\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep archive comments short (metadata pointers only).","Move large metadata into dedicated zip entries.","Enforce comment length at the producer, not the reader."],"tags":["zip","comment-limit","validation"],"backgroundTag":"zip-comment-too-long","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"}