{"record":{"id":"dab1a34e051b074e","repo":"iflytek/astron-agent","slug":"8317-toolbox-not-number-type","errorCode":"8317","errorMessage":"toolbox.not.number.type","messagePattern":"toolbox\\.not\\.number\\.type","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java","lineNumber":1439,"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                                jsonObject.put(item.getName(), 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                                jsonObject.put(item.getName(), Boolean.valueOf(String.valueOf(value)));\n                            } catch (Exception e) {\n                                log.error(value + \" is not Boolean type\");\n                                throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);\n                            }\n                            break;\n                        case STRING:\n                        default:\n                            jsonObject.put(item.getName(), item.getDft());\n                    }\n            }\n        });\n        return jsonObject;\n    }\n\n    private JSONObject convertWebSchemaTORequestJSON(JSONObject webSchemaObject) {\n        JSONObject retObject = new JSONObject();\n        // Input\n        JSONArray toolUrlParams = webSchemaObject.getJSONArray(\"toolUrlParams\");\n        JSONObject toolUrlParamsTarget = new JSONObject();\n        convertRequestParams(toolUrlParams, toolUrlParamsTarget);\n        retObject.put(\"toolUrlParams\", toolUrlParamsTarget);","sourceCodeStart":1421,"sourceCodeEnd":1457,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1421-L1457","documentation":"Thrown by ToolBoxService's NUMBER branch of the object-parameter conversion: in the BOOLEAN case the catch block throws ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE (a copy-paste artifact — the message is \"toolbox.not.number.type\" even though the failure came from boolean coercion). This is an internal mislabeling in ToolBoxService around line 1439; the underlying problem is still a value that does not fit the declared parameter type.","triggerScenarios":"A toolbox tool schema declares a BOOLEAN named parameter and the caller supplies a value that cannot be coerced (e.g. a nested object/array, or \"yes\"/0 in contexts where coercion fails) — the API then reports it misleadingly as a NUMBER-type error.","commonSituations":"Schema edited so a field changed type but callers still send the old format; 0/1 flags sent for booleans; complex payloads pasted into boolean fields.","solutions":["Ignore the misleading 'number' wording: send true/false (or \"true\"/\"false\") for the BOOLEAN-typed parameter.","Check the logged offending value to find the actual mismatched field.","Align the tool schema with what callers actually send (declare STRING/OBJECT if needed).","As a maintainability fix, change the catch block at ToolBoxService.java:1439 to throw ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE so future errors are labeled correctly."],"exampleFix":"// before (ToolBoxService.java, BOOLEAN case)\nthrow new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);\n// after\nthrow new BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE);","handlingStrategy":"try-catch","validationCode":"for (var e : booleanParams.entrySet()) {\n    Object v = e.getValue();\n    boolean ok = v instanceof Boolean || (v instanceof String s && s.matches(\"(?i)true|false\"));\n    if (!ok) throw new IllegalArgumentException(\"Param \" + e.getKey() + \" must be boolean\");\n}","typeGuard":"boolean isBoolean(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    // NOTE: code TOOLBOX_NOT_NUMBER_TYPE (8317) may actually mean a BOOLEAN\n    // coercion failure at ToolBoxService.java:1439 — inspect boolean params too\n}","preventionTips":["When this 'not number' error appears for a schema you believe is numeric, also check BOOLEAN-typed params — the throw site is mislabeled.","Send true/false only; avoid 0/1.","File/apply a fix changing the catch at line 1439 to throw TOOLBOX_NOT_BOOLEAN_TYPE."],"tags":["java","type-validation","toolbox","misleading-error"],"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"}