{"record":{"id":"46c6bb755b6b6594","repo":"apache/incubator-seata","slug":"unknown-branchtype-ordinal-46c6bb","errorCode":null,"errorMessage":"Unknown BranchType[{ordinal}]","messagePattern":"Unknown BranchType\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/seata/core/model/BranchType.java","lineNumber":73,"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","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/core/src/main/java/org/apache/seata/core/model/BranchType.java#L55-L91","documentation":"BranchType.get(int) maps a numeric branch type from the protocol back to the BranchType enum (AT, XA, TCC, SAGA). It throws when the ordinal does not match any enum entry, meaning the decoded integer is not a branch type this build knows.","triggerScenarios":"A branch register/undo message arrives carrying a branch-type byte outside 0..3 for this version, or protocol bytes are misaligned/corrupt so a different field is read as the branch type.","commonSituations":"Version skew (a future enum entry sent to an old build), non-Seata clients on the TC port, or framing corruption introduced by a TCP proxy that modifies the byte stream.","solutions":["Align Seata versions on both ends of the RPC connection.","Ensure point-to-point TCP between RM/TM and TC — no HTTP-style proxies or middleboxes rewriting the stream.","Enable protocol debug logs (org.apache.seata.rpc) and inspect the failing RpcMessage id/type to locate which message decodes badly."],"exampleFix":"# before: mixed versions\nrm seata 1.4 -> tc seata 2.2\n# after\nrm seata 2.2 -> tc seata 2.2","handlingStrategy":"type-guard","validationCode":"static boolean validBranchOrdinal(int o) {\n    for (BranchType b : BranchType.values()) if (b.ordinal() == o) return true;\n    return false;\n}","typeGuard":"static Optional<BranchType> safeBranch(int o) {\n    return Arrays.stream(BranchType.values()).filter(b -> b.ordinal() == o).findFirst();\n}","tryCatchPattern":"catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown BranchType\")) { closeChannelSafely(); LOG.warn(\"protocol mismatch: {}\", e.getMessage()); }\n    else throw e;\n}","preventionTips":["Version-check both ends at connect time","Never expose the TC RPC port to non-Seata workloads"],"tags":["protocol","enum","branch-type","decode"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}