alibaba/spring-ai-alibaba · error · IllegalArgumentException
参数 %s 的值 '%s' 应该是数值类型
Error message
参数 %s 的值 '%s' 应该是数值类型
What it means
ModelConfigParser.validateNumericValue throws this IllegalArgumentException when a model config parameter that must be numeric has a value that cannot be parsed as a number (the NumberFormatException branch rethrows a variant message, and any remaining non-numeric value reaches the final throw). It guards DashScope/studio model configuration parsing so numeric fields like temperature or max tokens are valid numbers.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/ModelConfigParser.java:258
* @param parameterName 参数名
* @param value 参数值
*/
private void validateNumericValue(String parameterName, Object value) {
if (value instanceof Number) {
return; // 已经是数值类型
}
if (value instanceof String) {
try {
Double.parseDouble((String) value);
return; // 可以转换为数值
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
String.format("参数 %s 的值 '%s' 不是有效的数值", parameterName, value));
}
}
throw new IllegalArgumentException(String.format("参数 %s 的值 '%s' 应该是数值类型", parameterName, value));
}
}
View on GitHub (pinned to f82da0b50f)
Solutions
- Set the parameter value to a valid number string (e.g. "0.7", "1024") in the model config.
- Strip units, whitespace, and locale separators (use '.' as decimal point) from the value.
- If the field should not be numeric, change the parameter name/type in the config schema instead of forcing it through numeric validation.
- Catch IllegalArgumentException around ModelConfigParser calls to surface a user-friendly message naming the offending parameter.
Example fix
// before
properties.put("temperature", "0,7");
// after
properties.put("temperature", "0.7"); Defensive patterns
Strategy: validation
Validate before calling
static boolean isNumeric(String v) { try { Double.parseDouble(v == null ? "" : v.trim()); return true; } catch (NumberFormatException e) { return false; } }
// call before parser: if (!isNumeric(raw)) throw new IllegalArgumentException("Value must be numeric: " + raw); Try / catch
try { parser.validateParameterTypes(config); } catch (IllegalArgumentException e) { log.error("Bad model config: {}", e.getMessage()); }
// or as NumberFormatException is the root cause:
try { Double.parseDouble(value); } catch (NumberFormatException e) { /* prompt user for a numeric value */ } Prevention
- Always store numeric config as plain dot-decimal strings.
- Strip units/whitespace from user input before parsing.
- Add schema-level type checks in studio config forms (input type=number).
When it happens
Trigger: Calling validateNumericValue (indirectly via validateParameterTypes during model config parsing) with a parameter value like "hot", "", or "1.2.3" that fails numeric parsing or is not numeric at all.
Common situations: Typing a non-numeric value into a studio admin model config field, pasting config with locale-formatted numbers (e.g. "0,7"), or whitespace/unit suffixes like "1024 tokens".
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- AgentScope routing flow requires root agent to be AgentScope
- Tool not found with id: <id>
- Unknown agent status code:
- Unknown agent type code:
- Invalid MessageType value:
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/02b7d3f4f7a1788c.
Report an issue: GitHub.