prestodb/presto · error · PrestoException

DRUID_SEGMENT_LOAD_ERROR

DRUID_SEGMENT_LOAD_ERROR

Error message

File comment too long. Is %d; max %d.

What it means

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.

Source

Thrown at presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileData.java:85

        comment = "";
        entries = new LinkedHashMap<>();
    }

    public Charset getCharset()
    {
        return charset;
    }

    public String getComment()
    {
        return comment;
    }

    public void setComment(byte[] comment)
    {
        checkArgument(comment != null, "Zip file comment could not be null");
        if (comment.length > 0xffff) {
            throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, format("File comment too long. Is %d; max %d.", comment.length, 0xffff));
        }
        this.comment = fromBytes(comment);
    }

    public void setComment(String comment)
    {
        setComment(getBytes(comment));
    }

    public long getCentralDirectorySize()
    {
        return centralDirectorySize;
    }

    public void setCentralDirectorySize(long centralDirectorySize)
    {
        this.centralDirectorySize = centralDirectorySize;
        if (centralDirectorySize > 0xffffffffL) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Truncate the comment to <= 65535 bytes before calling setComment.
  2. Move large metadata into a dedicated zip entry (e.g., meta.json) instead of the archive comment.
  3. Compress the metadata and store a short reference in the comment if a pointer is needed.
  4. Assert the comment length in the producer pipeline before writing the zip.

Example fix

// before
zipFileData.setComment(largeMetadataJson);
// after
if (largeMetadataJson.length > 0xffff) {
    largeMetadataJson = largeMetadataJson.substring(0, 0xffff);
}
zipFileData.setComment(largeMetadataJson);
Defensive patterns

Strategy: validation

Validate before calling

if (comment != null && comment.length > 0xffff) {
    comment = Arrays.copyOf(comment, 0xffff);
}
zipFileData.setComment(comment);

Try / catch

try {
    zipFileData.setComment(comment);
} catch (PrestoException e) {
    if (String.valueOf(e.getMessage()).startsWith("File comment too long")) {
        zipFileData.setComment(Arrays.copyOf(comment, 0xffff));
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling setComment(byte[]) (or the String overload via read) with a comment longer than 65535 bytes.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/5fc5ccc8e1761f9a. Report an issue: GitHub.