{"record":{"id":"f9d8c126170c8434","repo":"apache/incubator-seata","slug":"unknown-session-mode","errorCode":null,"errorMessage":"unknown session mode:{}","messagePattern":"unknown session mode:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/seata/common/store/SessionMode.java","lineNumber":49,"sourceCode":"    REDIS(\"redis\"),\n    /**\n     * raft store\n     */\n    RAFT(\"raft\");\n\n    private String name;\n\n    SessionMode(String name) {\n        this.name = name;\n    }\n\n    public static SessionMode get(String name) {\n        for (SessionMode mode : SessionMode.values()) {\n            if (mode.getName().equalsIgnoreCase(name)) {\n                return mode;\n            }\n        }\n        throw new IllegalArgumentException(\"unknown session mode:\" + name);\n    }\n\n    /**\n     * whether contains value of store mode\n     *\n     * @param name the mode name\n     * @return the boolean\n     */\n    public static boolean contains(String name) {\n        try {\n            return get(name) != null ? true : false;\n        } catch (IllegalArgumentException e) {\n            return false;\n        }\n    }\n\n    public String getName() {\n        return name;","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/store/SessionMode.java#L31-L67","documentation":"SessionMode.get(name) maps a configuration string to the SessionMode enum (file, db, redis, raft) case-insensitively; unknown values throw IllegalArgumentException 'unknown session mode:<name>'. SessionMode.contains() provides a non-throwing membership test.","triggerScenarios":"Configuring session store mode (e.g. sessionMode/seata.server.sessionMode, session.mode properties or programmatic SessionMode.get(cfg)) with a value not in {file, db, redis, raft}, including null/empty/typo values.","commonSituations":"Setting 'mysql' or 'database' instead of 'db'; leaving the property blank so an empty string is passed; version upgrades where a mode was renamed; copy-pasting store.mode values into session mode.","solutions":["Use exactly file, db, redis, or raft for the session mode setting.","Verify the property is set and not empty at runtime before calling SessionMode.get.","Use SessionMode.contains(name) to pre-validate config values."],"exampleFix":"# before\nsession.mode=database\n\n# after\nsession.mode=db","handlingStrategy":"validation","validationCode":"String mode = config.get(\"session.mode\");\nif (!SessionMode.contains(mode)) {\n    throw new IllegalArgumentException(\"session.mode must be one of file/db/redis/raft, got: \" + mode);\n}\nSessionMode sessionMode = SessionMode.get(mode);","typeGuard":null,"tryCatchPattern":"try {\n    SessionMode mode = SessionMode.get(name);\n} catch (IllegalArgumentException e) {\n    // echo valid values file/db/redis/raft in the config error to speed up fixing\n    throw e;\n}","preventionTips":["Use the literal values file, db, redis, raft for session mode.","Guard against blank values from unset environment variables before calling get().","Validate mode properties once at boot rather than on first use deep in runtime code."],"tags":["configuration","enum","session-store","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}