{"record":{"id":"7689925aad382cde","repo":"alibaba/spring-ai-alibaba","slug":"s-s","errorCode":null,"errorMessage":"参数 %s 的值 '%s' 不是有效的数值","messagePattern":"参数 (.+?) 的值 '(.+?)' 不是有效的数值","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/ModelConfigParser.java","lineNumber":253,"sourceCode":"    }\n    \n    /**\n     * 验证数值类型的参数值\n     *\n     * @param parameterName 参数名\n     * @param value         参数值\n     */\n    private void validateNumericValue(String parameterName, Object value) {\n        if (value instanceof Number) {\n            return; // 已经是数值类型\n        }\n        \n        if (value instanceof String) {\n            try {\n                Double.parseDouble((String) value);\n                return; // 可以转换为数值\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\n                        String.format(\"参数 %s 的值 '%s' 不是有效的数值\", parameterName, value));\n            }\n        }\n        \n        throw new IllegalArgumentException(String.format(\"参数 %s 的值 '%s' 应该是数值类型\", parameterName, value));\n    }\n}\n","sourceCodeStart":235,"sourceCodeEnd":261,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/ModelConfigParser.java#L235-L261","documentation":"An IllegalArgumentException thrown by validateNumericValue (invoked from validateParameterTypes) when a model parameter declared as numeric receives a String value that cannot be parsed by Double.parseDouble. The message names the offending parameter and its value.","triggerScenarios":"Calling validateModelConfig where a parameter known to be numeric (e.g. temperature, top_p) is supplied as a non-numeric string like 'hot', '0,7' (comma decimal separator), or '0.7 ' with stray characters. Non-String, non-Number values take the separate '应该是数值类型' branch instead.","commonSituations":"User-entered parameters from a form stored as strings; locale-formatted numbers using ',' as decimal separator; copied values with units ('0.9f', '70%'); schema drift after parameter type changes.","solutions":["Convert the value to a valid number before storing/passing it (use '.' decimal separator, no units).","Parse with the intended locale first, or normalize the string (trim, replace ',' with '.') prior to validation.","Fix the parameter's declared type if it is genuinely not numeric so validateParameterTypes skips it.","Catch IllegalArgumentException in the caller and surface a field-level message naming the parameter."],"exampleFix":"// before\nparams.put(\"temperature\", \"0,7\"); // '0,7' -> Double.parseDouble fails\nparser.validateModelConfig(info);\n// after\nparams.put(\"temperature\", Double.parseDouble(\"0,7\".replace(',', '.')));\nparser.validateModelConfig(info); // ok","handlingStrategy":"validation","validationCode":"Object v = params.get(name);\nif (v instanceof String s) { try { Double.parseDouble(s.trim().replace(',', '.')); } catch (NumberFormatException e) { throw new BadRequestException(\"parameter \" + name + \" must be numeric\"); } }","typeGuard":"boolean isNumericValue = v instanceof Number || (v instanceof String s && s.matches(\"\\\\s*-?\\\\d+(\\\\.\\\\d+)?([eE][+-]?\\\\d+)?\\\\s*\"));","tryCatchPattern":"try { parser.validateModelConfig(info); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"不是有效的数值\")) { /* fix the named parameter */ } throw e; }","preventionTips":["Store numeric parameters as JSON numbers, not strings","Normalize locale-specific decimal separators on input","Strip units/symbols from user-entered numbers before saving"],"tags":["validation","numeric","model-parameters"],"backgroundTag":"invalid-argument-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}