{"record":{"id":"14b883571c771a46","repo":"alibaba/canal","slug":"parseuuidset-failed-due-to-wrong-format-s","errorCode":null,"errorMessage":"parseUUIDSet failed due to wrong format: %s","messagePattern":"parseUUIDSet failed due to wrong format: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java","lineNumber":105,"sourceCode":"    /**\n     * 解析如下格式字符串为UUIDSet: 726757ad-4455-11e8-ae04-0242ac110002:1 => UUIDSet{SID:\n     * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:2}]}\n     * 726757ad-4455-11e8-ae04-0242ac110002:1-3 => UUIDSet{SID:\n     * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4}]}\n     * 726757ad-4455-11e8-ae04-0242ac110002:1-3:4 UUIDSet{SID:\n     * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:5}]}\n     * 726757ad-4455-11e8-ae04-0242ac110002:1-3:7-9 UUIDSet{SID:\n     * 726757ad-4455-11e8-ae04-0242ac110002, intervals: [{start:1, stop:4},\n     * {start:7, stop:10}]}\n     *\n     * @param str\n     * @return\n     */\n    public static UUIDSet parse(String str) {\n        String[] ss = str.split(\":\");\n\n        if (ss.length < 2) {\n            throw new RuntimeException(String.format(\"parseUUIDSet failed due to wrong format: %s\", str));\n        }\n\n        List<Interval> intervals = new ArrayList<>();\n        for (int i = 1; i < ss.length; i++) {\n            intervals.add(parseInterval(ss[i]));\n        }\n\n        UUIDSet uuidSet = new UUIDSet();\n        uuidSet.SID = UUID.fromString(ss[0]);\n        uuidSet.intervals = combine(intervals);\n\n        return uuidSet;\n    }\n\n    @Override\n    public String toString() {\n        StringBuilder sb = new StringBuilder();\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/UUIDSet.java#L87-L123","documentation":"Thrown by UUIDSet.parse(String) when the input string does not contain at least one ':' separating the UUID (SID) from its transaction-id intervals. The parser splits on ':' and requires a minimum of two segments: the UUID and at least one interval such as '1-3'. The canonical GTID-set format is '<UUID>:<interval>[:<interval>...]'. Without the delimiter, no UUID/interval split is possible and the whole value is treated as malformed.","triggerScenarios":"Calling UUIDSet.parse(str) with a string that has no ':' (e.g. '726757ad-4455-11e8-ae04-0242ac110002'), an empty string, or a value whose first segment is a bare UUID with no interval suffix. Also triggered when downstream code feeds a GTID string that has been truncated or already had its interval portion stripped.","commonSituations":"Manually constructed GTID strings missing the interval part; copying only the UUID portion from 'show master status'; a custom binlog position parser that trims at the wrong delimiter; GTID values read from a config file where trailing intervals were lost; database upgraded to a GTID representation the older parser does not expect.","solutions":["Ensure the input string matches '<UUID>:<interval>' e.g. '726757ad-4455-11e8-ae04-0242ac110002:1-3' before calling parse.","Validate the string with a regex such as '^[0-9a-fA-F-]{36}:.+$' and reject/repair malformed input upstream.","If you only have a UUID, append a default interval (e.g. ':1') or skip UUIDSet parsing entirely.","Log the raw str value at the call site to find which producer emitted the bad GTID string."],"exampleFix":"// before\nUUIDSet set = UUIDSet.parse(gtidStr); // gtidStr = \"726757ad-4455-11e8-ae04-0242ac110002\"\n\n// after\nif (gtidStr == null || !gtidStr.contains(\":\")) {\n    throw new IllegalArgumentException(\"Invalid GTID set, expected '<UUID>:<interval>': \" + gtidStr);\n}\nUUIDSet set = UUIDSet.parse(gtidStr);","handlingStrategy":"validation","validationCode":"public static boolean isValidGtidSet(String s) {\n    return s != null && s.matches(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}:.+\");\n}\n// before UUIDSet.parse(str): if (!isValidGtidSet(str)) throw new IllegalArgumentException(...);","typeGuard":"public static boolean isParsableGtidSet(String s) {\n    if (s == null) return false;\n    String[] parts = s.split(\":\");\n    if (parts.length < 2) return false;\n    try { java.util.UUID.fromString(parts[0]); return true; }\n    catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n    UUIDSet set = UUIDSet.parse(str);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"parseUUIDSet failed\")) {\n        // log str, reject position, surface a clear config error\n    }\n    throw e;\n}","preventionTips":["Always validate GTID strings against the documented '<UUID>:<interval>' shape before parsing.","Log the raw value at the boundary where GTIDs enter the system (config, DB read).","Never hand-build GTID strings by concatenating a UUID alone."],"tags":["parsing","gtid","mysql","validation","runtime-exception"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}