{"record":{"id":"b3a2b559b38573bc","repo":"dromara/Sa-Token","slug":"key","errorCode":null,"errorMessage":"参数${key}不能为空","messagePattern":"参数(.+?)不能为空","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"sa-token-demo/sa-token-demo-oauth2/sa-token-demo-oauth2-client/src/main/java/com/pj/utils/SoMap.java","lineNumber":525,"sourceCode":"\t/** 与isNull()相反 */\n\tpublic boolean isNotNull(String key) {\n\t\treturn !isNull(key);\n\t}\n\t/** 指定key的value是否为null，作用同isNotNull() */\n\tpublic boolean has(String key) {\n\t\treturn !isNull(key);\n\t}\n\t\n\t/** 指定value在此SoMap的判断标准中是否为null */\n\tpublic boolean valueIsNull(Object value) {\n\t\treturn NULL_ELEMENT_LIST.contains(value);\n\t}\n\t\n\t/** 验证指定key不为空，为空则抛出异常 */\n\tpublic SoMap checkNull(String ...keys) {\n\t\tfor (String key : keys) {\n\t\t\tif(this.isNull(key)) {\n\t\t\t\tthrow new RuntimeException(\"参数\" + key + \"不能为空\");\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\tstatic Pattern patternNumber = Pattern.compile(\"[0-9]*\");\n\t/** 指定key是否为数字 */\n\tpublic boolean isNumber(String key) {\n\t\tString value = getString(key);\n\t\tif(value == null) {\n\t\t\treturn false;\n\t\t}\n\t    return patternNumber.matcher(value).matches();   \n\t}\n\n\t\n\t\n\t","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-demo/sa-token-demo-oauth2/sa-token-demo-oauth2-client/src/main/java/com/pj/utils/SoMap.java#L507-L543","documentation":"Thrown by SoMap.checkNull(String... keys) when any requested key is null under SoMap's loose null standard (null, empty string, or one of NULL_ELEMENT_LIST like \"null\"/\"NaN\"). It is a deliberate parameter-validation guard used by the OAuth2 client demo controllers to fail fast on missing input.","triggerScenarios":"Calling soMap.checkNull(\"client_id\", \"response_type\") when the HTTP request is missing one of those parameters, or the parameter value is the literal string \"null\" / empty. Also fires when getRequestSoMap() was populated from a request whose parameter names don't match exactly (case-sensitive).","commonSituations":"OAuth2 authorize/token endpoints called with missing client_id, redirect_uri, or a form body that was not parsed (wrong Content-Type), or query vs form parameter mix-ups.","solutions":["Send all required parameters; check the exception message for the exact missing key name.","Verify parameter names are case-sensitive matches and the body is application/x-www-form-urlencoded when posting.","For optional fields, remove the key from the checkNull list and test with isNull(key) instead.","Ensure getRequestSoMap() is called on the request thread (see error 104) so parameters are actually populated."],"exampleFix":"// before\nSoMap soMap = SoMap.getRequestSoMap();\nsoMap.checkNull(\"client_id\", \"response_type\", \"redirect_uri\");\n\n// after\nSoMap soMap = SoMap.getRequestSoMap();\nif (soMap.isNull(\"client_id\")) {\n    return SaResult.error(\"missing client_id\");\n}\nsoMap.checkNull(\"response_type\", \"redirect_uri\");","handlingStrategy":"validation","validationCode":"for (String key : new String[]{\"client_id\", \"response_type\"}) {\n    if (soMap.isNull(key)) {\n        return SaResult.error(\"missing param: \" + key);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate at the controller boundary and return a structured 400 instead of letting checkNull's RuntimeException bubble.","Send required params with correct case and form-encoded bodies; checkNull is case-sensitive."],"tags":["validation","somap","required-params","oauth2-client"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}