dromara/Sa-Token · error · SaSsoException

CODE_30024

CODE_30024

Error message

缺少参数:{key}

What it means

Thrown by SaSsoMessage.getValueNotNull(String key) when the requested key is absent or its value is empty. This is a strict-read accessor: the SSO protocol expects mandatory fields (loginId, ticket, client, etc.) to be present, and a missing one means the peer sent an incomplete or malformed message.

Source

Thrown at sa-token-plugin/sa-token-sso/src/main/java/cn/dev33/satoken/sso/message/SaSsoMessage.java:121

    }

    @Override
    public SaSsoMessage delete(String key) {
        super.remove(key);
        return this;
    }

    // -----------

    /**
     * 获取一个值 (此值必须存在,否则抛出异常 )
     * @param key 键
     * @return 参数值
     */
    public Object getValueNotNull(String key) {
        Object value = get(key);
        if(SaFoxUtil.isEmpty(value)) {
            throw new SaSsoException("缺少参数:" + key).setCode(SaSsoErrorCode.CODE_30024);
        }
        return value;
    }

}

View on GitHub (pinned to ac2c7f6e94)

Solutions

  1. Log the full message map (msg.getDataMap()) to see which keys actually arrived
  2. Align paramName configuration (sa-token.sso.param-name.*) between sso-server and sso-client so both sides use the same key names
  3. Upgrade client and server to the same sa-token version so the message contract matches

Example fix

// before
Object loginId = message.getValueNotNull("loginId"); // throws if server used a custom param name

// after
// align param names, or read defensively
Object loginId = message.get(paramName.loginId);
if(SaFoxUtil.isEmpty(loginId)) {
    throw new SaSsoException("server response missing loginId");
}
Defensive patterns

Strategy: validation

Validate before calling

Object v = message.get(key);
if(SaFoxUtil.isEmpty(v)) {
    // return 400 / log which key is missing instead of throwing deep in processing
}

Try / catch

try { message.getValueNotNull(key); } catch (SaSsoException e) { if(SaSsoErrorCode.CODE_30024 == e.getCode()) { /* log message map, reject */ } }

Prevention

When it happens

Trigger: Calling getValueNotNull("loginId") / getValueNotNull("ticket") on a SaSsoMessage whose map lacks that key, typically when processing a check-ticket or logout response from sso-server that did not include the expected parameter.

Common situations: The sso-server and sso-client run different sa-token versions with different parameter names (customized paramName); a proxy or gateway stripped query/body parameters; the server responded with a business failure payload instead of the expected data.

Related errors


AI-assisted analysis of dromara/Sa-Token@ac2c7f6e94 (2026-08-14). Data as JSON: /api/errors/8b2dcde7eeee5af1. Report an issue: GitHub.