{"record":{"id":"534326a192f62cda","repo":"iflytek/astron-agent","slug":"toolbox-not-boolean-type","errorCode":"TOOLBOX_NOT_BOOLEAN_TYPE","errorMessage":"BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE)","messagePattern":"BusinessException\\(ResponseEnum\\.TOOLBOX_NOT_BOOLEAN_TYPE\\)","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java","lineNumber":1404,"sourceCode":"                                    } catch (Exception e) {\n                                        log.error(value + \" is not Number type\");\n                                        throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);\n                                    }\n                                    break;\n                                case INTEGER:\n                                    try {\n                                        array.add(Long.valueOf(String.valueOf(value)));\n                                    } catch (Exception e) {\n                                        log.error(value + \" is not Integer type\");\n                                        throw new BusinessException(ResponseEnum.TOOLBOX_NOT_INTEGER_TYPE);\n                                    }\n                                    break;\n                                case BOOLEAN:\n                                    try {\n                                        array.add(Boolean.valueOf(String.valueOf(value)));\n                                    } catch (Exception e) {\n                                        log.error(value + \" is not Boolean type\");\n                                        throw new BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE);\n                                    }\n                                    break;\n                                case STRING:\n                                default:\n                                    array.add(value);\n                            }\n                        }\n                    }\n                    jsonObject.put(item.getName(), array);\n                    break;\n                default:\n                    Object value = item.getDft();\n                    switch (item.getType()) {\n                        case NUMBER:\n                            try {\n                                jsonObject.put(item.getName(), Double.valueOf(String.valueOf(value)));\n                            } catch (Exception e) {\n                                log.error(value + \" is not Number type\");","sourceCodeStart":1386,"sourceCodeEnd":1422,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1386-L1422","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"items\": [0, 1]}\n// after\n{\"items\": [false, true]}","handlingStrategy":"type-guard","validationCode":"boolean isBooleanLike(Object v) {\n    return v instanceof Boolean\n        || (v instanceof String s && (s.equalsIgnoreCase(\"true\") || s.equalsIgnoreCase(\"false\")));\n}\n// ensure every element passes before the call","typeGuard":"boolean isStrictBoolean(Object v) {\n    return v instanceof Boolean\n        || (v instanceof String s && s.trim().matches(\"(?i)true|false\"));\n}","tryCatchPattern":"try {\n    toolBoxService.callTool(...);\n} catch (BusinessException e) {\n    if (\"TOOLBOX_NOT_BOOLEAN_TYPE\".equals(e.getCode())) {\n        // map 0/1 to false/true and retry once, else surface schema drift\n    }\n}","preventionTips":["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."],"tags":["java","type-validation","toolbox"],"backgroundTag":"type-mismatch","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}