{"record":{"id":"4242dc6fd014d5b7","repo":"apache/incubator-seata","slug":"unknown-globalstatus-code","errorCode":null,"errorMessage":"Unknown GlobalStatus[{code}]","messagePattern":"Unknown GlobalStatus\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/seata/core/model/GlobalStatus.java","lineNumber":189,"sourceCode":"     * @param code the code\n     * @return the global status\n     */\n    public static GlobalStatus get(byte code) {\n        return get((int) code);\n    }\n\n    /**\n     * Get global status.\n     *\n     * @param code the code\n     * @return the global status\n     */\n    public static GlobalStatus get(int code) {\n        GlobalStatus value = null;\n        try {\n            value = GlobalStatus.values()[code];\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\"Unknown GlobalStatus[\" + code + \"]\");\n        }\n        return value;\n    }\n\n    /**\n     * Is one phase timeout boolean.\n     *\n     * @param status the status\n     * @return the boolean\n     */\n    public static boolean isOnePhaseTimeout(GlobalStatus status) {\n        if (status == TimeoutRollbacking\n                || status == TimeoutRollbackRetrying\n                || status == TimeoutRollbacked\n                || status == TimeoutRollbackFailed) {\n            return true;\n        }\n        return false;","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/core/model/GlobalStatus.java#L171-L207","documentation":"Thrown by GlobalStatus.get(int) when the supplied code is not a valid ordinal into the GlobalStatus enum — negative, larger than the last declared value, or otherwise out of range. It converts a raw protocol/DB integer back into a typed status, so an unrecognized code means the data came from a newer or corrupt source.","triggerScenarios":"Calling GlobalStatus.get(code) with an integer that does not match any enum ordinal: decoding a session record written by a newer Seata version that added statuses, reading corrupted rows from the global_table/branch_table, or passing an arbitrary int from user code.","commonSituations":"Version skew: rolling upgrade where an old TC reads statuses written by a new TC; mixed client/server versions; manual SQL edits or data corruption in the transaction store; hand-constructed protocol messages.","solutions":["Align Seata versions across nodes so all participants know the same GlobalStatus set.","Audit the stored/transported code value (log it) and compare with the enum ordinals on this build.","Restore or repair corrupted transaction-store rows if the code is garbage.","Validate external int input against GlobalStatus.values().length before calling get()."],"exampleFix":"// before\nGlobalStatus status = GlobalStatus.get(rawCode); // throws for unknown code\n\n// after\nGlobalStatus[] all = GlobalStatus.values();\nGlobalStatus status = (rawCode >= 0 && rawCode < all.length)\n        ? all[rawCode]\n        : GlobalStatus.Begin; // or explicit error handling","handlingStrategy":"validation","validationCode":"public static GlobalStatus safeGet(int code) {\n    GlobalStatus[] all = GlobalStatus.values();\n    return (code >= 0 && code < all.length) ? all[code] : null;\n}","typeGuard":"boolean isKnownGlobalStatus(int code) {\n    return code >= 0 && code < GlobalStatus.values().length;\n}","tryCatchPattern":"try {\n    status = GlobalStatus.get(code);\n} catch (IllegalArgumentException e) {\n    LOGGER.error(\"unknown status code {} (version skew or corrupt store)\", code);\n    status = GlobalStatus.Begin; // quarantine the record instead of crashing\n}","preventionTips":["Bounds-check any externally sourced int against values().length before get().","Keep TC nodes on one Seata release during rolling upgrades.","Treat unknown status codes as data-integrity incidents — log the raw code."],"tags":["enum","version-mismatch","data-corruption","protocol"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}