{"record":{"id":"a2e80c6aba43c5a2","repo":"apache/incubator-seata","slug":"unknown-branchtype-ordinal","errorCode":null,"errorMessage":"Unknown BranchType[{ordinal}]","messagePattern":"Unknown BranchType\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compatible/src/main/java/io/seata/core/model/BranchType.java","lineNumber":70,"sourceCode":"     * @return the branch type\n     */\n    public static BranchType get(byte ordinal) {\n        return get((int) ordinal);\n    }\n\n    /**\n     * Get branch type.\n     *\n     * @param ordinal the ordinal\n     * @return the branch type\n     */\n    public static BranchType get(int ordinal) {\n        for (BranchType branchType : values()) {\n            if (branchType.ordinal() == ordinal) {\n                return branchType;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown BranchType[\" + ordinal + \"]\");\n    }\n\n    /**\n     * Get branch type.\n     *\n     * @param name the name\n     * @return the branch type\n     */\n    public static BranchType get(String name) {\n        for (BranchType branchType : values()) {\n            if (branchType.name().equalsIgnoreCase(name)) {\n                return branchType;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown BranchType[\" + name + \"]\");\n    }\n\n    public org.apache.seata.core.model.BranchType convertBranchType() {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compatible/src/main/java/io/seata/core/model/BranchType.java#L52-L88","documentation":"Compatible-layer BranchType.get(int): looks up a branch type by ordinal and throws when no constant matches. Branch types are AT, TCC, SAGA, XA; any other integer (from a foreign version or bad data) is rejected.","triggerScenarios":"Calling BranchType.get(ordinal) with an int outside the declared constants — during conversion of an io.seata BranchType to org.apache.seata BranchType (convertBranchType path), or when decoding branch records whose type code came from a mismatched build.","commonSituations":"Rolling upgrades between Seata versions that added/reordered BranchType constants; io.seata compatible shim used against a newer server; corrupted branch_table rows; hardcoded numeric branch types in scripts.","solutions":["Pin client, server, and compatible module to the same Seata release.","Use BranchType.get(name) (the String overload) instead of ordinals — names are stable across versions.","Inspect and repair any stored branch records containing invalid type codes.","Range-check the ordinal before conversion."],"exampleFix":"// before (ordinal is version-fragile)\norg.apache.seata.core.model.BranchType t =\n        io.seata.core.model.BranchType.get(rawOrdinal).convertBranchType();\n\n// after (name-based, stable)\norg.apache.seata.core.model.BranchType t =\n        org.apache.seata.core.model.BranchType.get(branchTypeNameString);","handlingStrategy":"validation","validationCode":"boolean isKnownBranchType(int ordinal) {\n    for (io.seata.core.model.BranchType t : io.seata.core.model.BranchType.values()) {\n        if (t.ordinal() == ordinal) return true;\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n    return BranchType.get(ordinal);\n} catch (IllegalArgumentException e) {\n    LOGGER.warn(\"unknown branch type ordinal {}\", ordinal);\n    return BranchType.AT; // or quarantine the record\n}","preventionTips":["Use the String-name form BranchType.get(name) instead of ordinals — names survive reordering.","Keep compatible and core modules on the same release.","Never persist branch types as ordinals; store the name."],"tags":["enum","compatibility","version-mismatch","branch-type"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}