{"record":{"id":"49214fe346763b2f","repo":"dromara/Sa-Token","slug":"code-30022","errorCode":"CODE_30022","errorMessage":"消息类型不可为空","messagePattern":"消息类型不可为空","errorType":"exception","errorClass":"SaSsoException","httpStatus":null,"severity":"error","filePath":"sa-token-plugin/sa-token-sso/src/main/java/cn/dev33/satoken/sso/message/SaSsoMessage.java","lineNumber":88,"sourceCode":"    public String getType() {\n        return getString(MSG_TYPE);\n    }\n\n    /**\n     * 设置消息类型\n     * @param type /\n     * @return /\n     */\n    public SaSsoMessage setType(String type) {\n        return set(MSG_TYPE, type);\n    }\n\n    /**\n     * 校验消息类型\n     */\n    public void checkType() {\n        if(SaFoxUtil.isEmpty(getString(MSG_TYPE))) {\n            throw new SaSsoException(\"消息类型不可为空\").setCode(SaSsoErrorCode.CODE_30022);\n        }\n    }\n\n    // -----------\n\n    @Override\n    public Object get(String key) {\n        return super.get(key);\n    }\n\n    @Override\n    public SaSsoMessage set(String key, Object value) {\n        super.put(key, value);\n        return this;\n    }\n\n    @Override\n    public SaSsoMessage delete(String key) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-plugin/sa-token-sso/src/main/java/cn/dev33/satoken/sso/message/SaSsoMessage.java#L70-L106","documentation":"Thrown by SaSsoMessage.checkType() when the message's type field (MSG_TYPE) is empty or null. In sa-token SSO, every SaSsoMessage exchanged between client and server must declare a type so that SaSsoMessageHolder can route it to a registered handler; an empty type makes the message unroutable.","triggerScenarios":"Calling message.checkType() on a SaSsoMessage that was built without setType(...), e.g. a custom message created via new SaSsoMessage() or parsed from a request body that lacks the type key.","commonSituations":"Writing a custom SSO message handler; deserializing an incoming SSO HTTP request payload where the client omitted the type field; upgrading to a sa-token version that made checkType() mandatory before dispatch.","solutions":["Call setType(\"your-message-type\") on the message before checkType() or before sending it","When parsing inbound messages, validate and set the type from the request parameter before invoking handleMessage","Register the type string in SaSsoMessageHolder so routing also succeeds after the check passes"],"exampleFix":"// before\nSaSsoMessage msg = new SaSsoMessage();\nmsg.set(\"key\", \"value\");\nmsg.checkType(); // throws CODE_30022\n\n// after\nSaSsoMessage msg = new SaSsoMessage();\nmsg.setType(\"sso-signout\");\nmsg.set(\"key\", \"value\");\nmsg.checkType();","handlingStrategy":"validation","validationCode":"if(SaFoxUtil.isEmpty(message.getString(SaSsoMessage.MSG_TYPE))) {\n    // reject / set default type before dispatch\n    message.setType(\"default-type\");\n}","typeGuard":null,"tryCatchPattern":"try { message.checkType(); } catch (SaSsoException e) { /* code 30022: log and reject inbound message */ }","preventionTips":["Always call setType(...) immediately when constructing a SaSsoMessage","Validate inbound SSO payloads at the controller boundary before handing them to the message holder"],"tags":["sa-token","sso","validation","message"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}