{"record":{"id":"438126a9baf98a6a","repo":"apache/incubator-seata","slug":"unknown-transactionexceptioncode-ordinal","errorCode":null,"errorMessage":"Unknown TransactionExceptionCode[{ordinal}]","messagePattern":"Unknown TransactionExceptionCode\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compatible/src/main/java/io/seata/core/exception/TransactionExceptionCode.java","lineNumber":167,"sourceCode":"     * @param ordinal the ordinal\n     * @return the transaction exception code\n     */\n    public static TransactionExceptionCode get(byte ordinal) {\n        return get((int) ordinal);\n    }\n\n    /**\n     * Get transaction exception code.\n     *\n     * @param ordinal the ordinal\n     * @return the transaction exception code\n     */\n    public static TransactionExceptionCode get(int ordinal) {\n        TransactionExceptionCode value = null;\n        try {\n            value = TransactionExceptionCode.values()[ordinal];\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\"Unknown TransactionExceptionCode[\" + ordinal + \"]\");\n        }\n        return value;\n    }\n\n    public org.apache.seata.core.exception.TransactionExceptionCode convertTransactionExceptionCode() {\n        return org.apache.seata.core.exception.TransactionExceptionCode.get(this.ordinal());\n    }\n}\n","sourceCodeStart":149,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compatible/src/main/java/io/seata/core/exception/TransactionExceptionCode.java#L149-L176","documentation":"Compatible-layer (io.seata) mirror of TransactionExceptionCode.get: it maps an ordinal back to the enum and throws IllegalArgumentException when the ordinal is out of range. This runs when legacy io.seata API objects convert wire/DB codes into typed exception codes.","triggerScenarios":"Calling TransactionExceptionCode.get(ordinal) with an int not matching any enum constant ordinal — typically during unwrap/convert of an io.seata exception payload whose code was produced by a different (newer or older) build.","commonSituations":"Applications mixing the old io.seata (compatible) artifacts with newer org.apache.seata clients/servers on the classpath or across the wire; deserializing codes persisted by another version; test fixtures using fabricated ordinals.","solutions":["Align the compatible module version with the Seata client/server version in use.","Log the offending ordinal and compare to the enum constants on both sides to find the skew.","Prefer the org.apache.seata API directly for new code so the compatibility conversion path is not exercised.","Range-check ordinals against values().length before calling get()."],"exampleFix":"// before\nTransactionExceptionCode code = TransactionExceptionCode.get(ordinal);\n\n// after\nTransactionExceptionCode[] all = TransactionExceptionCode.values();\nif (ordinal < 0 || ordinal >= all.length) {\n    throw new IllegalArgumentException(\"Unsupported exception code from peer: \" + ordinal);\n}\nTransactionExceptionCode code = all[ordinal];","handlingStrategy":"validation","validationCode":"boolean isKnownTxExceptionCode(int ordinal) {\n    TransactionExceptionCode[] all = TransactionExceptionCode.values();\n    return ordinal >= 0 && ordinal < all.length;\n}","typeGuard":null,"tryCatchPattern":"try {\n    return TransactionExceptionCode.get(ordinal);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"exception code \" + ordinal + \" unknown; check seata version alignment\", e);\n}","preventionTips":["Align io.seata compatible artifacts with the org.apache.seata release in use.","Prefer org.apache.seata APIs in new code to skip the ordinal-conversion bridge.","Bounds-check ordinals arriving from the wire or DB before mapping."],"tags":["enum","compatibility","version-mismatch","legacy"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}