iflytek/astron-agent · error · BusinessException
TOOLBOX_NOT_BOOLEAN_TYPE
TOOLBOX_NOT_BOOLEAN_TYPE
Error message
BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE)
What it means
Thrown by ToolBoxService when converting an array element whose declared parameter type is BOOLEAN and Boolean.valueOf-derived parsing was attempted but the value could not be coerced to a boolean. Note that in this codebase Boolean.valueOf never throws for strings (it returns false), so reaching this branch indicates the value is an unsuitable object type rather than a merely misspelled string.
Solutions
- Send real booleans (true/false) or the strings "true"/"false" for BOOLEAN array elements.
- Replace 0/1 numeric flags with true/false in the payload.
- If the value is genuinely complex, change the schema item type to OBJECT/STRING to match the payload.
- Inspect the logged offending value to identify the mismatched field.
Example fix
// before
{"items": [0, 1]}
// after
{"items": [false, true]} Defensive patterns
Strategy: type-guard
Validate before calling
boolean isBooleanLike(Object v) {
return v instanceof Boolean
|| (v instanceof String s && (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")));
}
// ensure every element passes before the call Type guard
boolean isStrictBoolean(Object v) {
return v instanceof Boolean
|| (v instanceof String s && s.trim().matches("(?i)true|false"));
} Try / catch
try {
toolBoxService.callTool(...);
} catch (BusinessException e) {
if ("TOOLBOX_NOT_BOOLEAN_TYPE".equals(e.getCode())) {
// map 0/1 to false/true and retry once, else surface schema drift
}
} Prevention
- Use real JSON booleans true/false, never 0/1 or "yes"/"no".
- If a boolean check never throws for plain strings, suspect non-string object values — inspect the payload shape.
- Regenerate clients after schema type changes.
When it happens
Trigger: Calling a toolbox tool whose schema declares an array item of type BOOLEAN while the caller supplies a non-boolean, non-string object (e.g. a nested JSON object, array, or number) for the element.
Common situations: Callers pass 0/1 integers as booleans; complex values are accidentally placed in a boolean-typed array field; schema and payload drifted after a tool definition update.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/534326a192f62cda.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:1404
} catch (Exception e) {
log.error(value + " is not Number type");
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);
}
break;
case INTEGER:
try {
array.add(Long.valueOf(String.valueOf(value)));
} catch (Exception e) {
log.error(value + " is not Integer type");
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_INTEGER_TYPE);
}
break;
case BOOLEAN:
try {
array.add(Boolean.valueOf(String.valueOf(value)));
} catch (Exception e) {
log.error(value + " is not Boolean type");
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE);
}
break;
case STRING:
default:
array.add(value);
}
}
}
jsonObject.put(item.getName(), array);
break;
default:
Object value = item.getDft();
switch (item.getType()) {
case NUMBER:
try {
jsonObject.put(item.getName(), Double.valueOf(String.valueOf(value)));
} catch (Exception e) {
log.error(value + " is not Number type");View on GitHub (pinned to 5e758547a8)