{"record":{"id":"9e65e156a4439045","repo":"alibaba/canal","slug":"format-description-event-header-length-is-too-shor","errorCode":null,"errorMessage":"Format Description event header length is too short","messagePattern":"Format Description event header length is too short","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/FormatDescriptionLogEvent.java","lineNumber":101,"sourceCode":"     * LOG_EVENT_MINIMAL_HEADER_LEN).\n     */\n    protected final int       commonHeaderLen;\n    protected int             numberOfEventTypes;\n\n    /** The list of post-headers' lengthes */\n    protected final short[]   postHeaderLen;\n    protected int[]           serverVersionSplit                  = new int[3];\n\n    public FormatDescriptionLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent)\n                                                                                                                    throws IOException{\n        /* Start_log_event_v3 */\n        super(header, buffer, descriptionEvent);\n\n        buffer.position(LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET);\n        commonHeaderLen = buffer.getUint8();\n        if (commonHeaderLen < OLD_HEADER_LEN) /* sanity check */\n        {\n            throw new IOException(\"Format Description event header length is too short\");\n        }\n\n        numberOfEventTypes = buffer.limit() - (LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET + 1);\n\n        // buffer.position(LOG_EVENT_MINIMAL_HEADER_LEN\n        // + ST_COMMON_HEADER_LEN_OFFSET + 1);\n        postHeaderLen = new short[numberOfEventTypes];\n        for (int i = 0; i < numberOfEventTypes; i++) {\n            postHeaderLen[i] = (short) buffer.getUint8();\n        }\n\n        calcServerVersionSplit();\n        long calc = getVersionProduct();\n        if (calc >= checksumVersionProduct) {\n            /*\n             * the last bytes are the checksum alg desc and value (or value's room)\n             */\n            numberOfEventTypes -= BINLOG_CHECKSUM_ALG_DESC_LEN;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/FormatDescriptionLogEvent.java#L83-L119","documentation":"Thrown during construction of a FormatDescriptionLogEvent when the common header length field read from the event is less than OLD_HEADER_LEN (the minimum valid common header size for the binlog format). This sanity check ensures the event declares a header large enough to contain the required fields. A too-short header means the binlog format is either corrupt or from an unrecognized source.","triggerScenarios":"Constructing FormatDescriptionLogEvent from a binlog stream. At offset LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET, a uint8 is read as commonHeaderLen. If commonHeaderLen < OLD_HEADER_LEN, the exception fires.","commonSituations":"Binlog from an unsupported MySQL/MariaDB version with a different format description structure, a corrupt or truncated binlog file, or the parser is positioned at the wrong offset (not actually at a FORMAT_DESCRIPTION_EVENT).","solutions":["Verify the binlog file is from a supported MySQL version (3.23, 4.0, 4.x, 5.x, 8.x).","Check that the parser is positioned at the actual start of a FORMAT_DESCRIPTION_EVENT — if the position is wrong, the header bytes will be misinterpreted.","Use mysqlbinlog to verify the file is valid and readable.","Check for binlog file corruption (incomplete writes, disk errors)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-validate before constructing FormatDescriptionLogEvent\nbuffer.position(LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET);\nint headerLen = buffer.getUint8();\nif (headerLen < FormatDescriptionLogEvent.OLD_HEADER_LEN) {\n    logger.warn(\"Format description common header len {} is below minimum {}\",\n        headerLen, FormatDescriptionLogEvent.OLD_HEADER_LEN);\n    // use default format description\n}","typeGuard":null,"tryCatchPattern":"try {\n    FormatDescriptionLogEvent fd = new FormatDescriptionLogEvent(header, buffer, descriptionEvent);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"header length is too short\")) {\n        logger.error(\"Binlog format description header too short — corrupt or unsupported format\");\n    }\n    throw e;\n}","preventionTips":["Verify the binlog file starts with a valid FORMAT_DESCRIPTION_EVENT.","Ensure the parser is connected to a supported MySQL/MariaDB version.","Use mysqlbinlog to validate binlog file integrity before parsing."],"tags":["binlog","mysql","format-description","header-validation","version-compat"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}