{"record":{"id":"d836970a2bae424a","repo":"iflytek/astron-agent","slug":"toolbox-not-number-type","errorCode":"TOOLBOX_NOT_NUMBER_TYPE","errorMessage":"BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE)","messagePattern":"BusinessException\\(ResponseEnum\\.TOOLBOX_NOT_NUMBER_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":1388,"sourceCode":"                case OBJECT:\n                    JSONObject obj = recurGenRunParam(item.getChildren());\n                    jsonObject.put(item.getName(), obj);\n                    break;\n                case ARRAY:\n                    JSONArray array = new JSONArray();\n                    for (WebSchemaItem childItem : item.getChildren()) {\n                        if (OBJECT.equals(childItem.getType())) {\n                            JSONObject objItem = recurGenRunParam(childItem.getChildren());\n                            array.add(objItem);\n                        } else {\n                            Object value = childItem.getDft();\n                            switch (childItem.getType()) {\n                                case NUMBER:\n                                    try {\n                                        array.add(Double.valueOf(String.valueOf(value)));\n                                    } 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;","sourceCodeStart":1370,"sourceCodeEnd":1406,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1370-L1406","documentation":"Thrown by ToolBoxService when converting an array element whose declared parameter type is NUMBER: Double.valueOf(String.valueOf(value)) failed because the value string is not parseable as a double. The service enforces strict runtime type matching between a tool's declared input schema and the actual values supplied by the caller.","triggerScenarios":"Calling a toolbox tool API whose schema declares an array item of type NUMBER while the caller supplies an array element whose string form is not a valid double (e.g. \"abc\", empty string, null, or \"1.2.3\").","commonSituations":"Frontend sends user-entered text for a numeric field; JSON numbers arrive as strings with locale formatting (\"1,234.5\"); upstream workflow passes empty or null values for optional numeric array items.","solutions":["Fix the caller to send a valid numeric value for every NUMBER-typed array element (plain decimal, no thousand separators or units).","Sanitize/convert values before the call (e.g. parse client-side with Number(value) and reject NaN, trim whitespace).","If the values are legitimately non-numeric, correct the tool's schema so the array item type is STRING instead of NUMBER.","Check logs (ToolBoxService logs the offending value) to identify which field carried the bad value."],"exampleFix":"// before\n{\"items\": [\"12.5\", \"not-a-number\"]}\n// after\n{\"items\": [12.5, 3.14]}","handlingStrategy":"validation","validationCode":"boolean isNumber(Object v) {\n    if (v == null) return false;\n    try { Double.parseDouble(String.valueOf(v).trim()); return true; }\n    catch (NumberFormatException e) { return false; }\n}\n// call before API: if (!items.stream().allMatch(this::isNumber)) throw ...;","typeGuard":"boolean isNumericString(Object v) {\n    return v instanceof Number\n        || (v instanceof String s && s.trim().matches(\"-?\\\\d+(\\\\.\\\\d+)?([eE][+-]?\\\\d+)?\"));\n}","tryCatchPattern":"try {\n    toolBoxService.callTool(...);\n} catch (BusinessException e) {\n    if (\"TOOLBOX_NOT_NUMBER_TYPE\".equals(e.getCode())) {\n        // report which array element is non-numeric and fix payload\n    }\n}","preventionTips":["Validate all NUMBER-typed inputs with Double.parseDouble before calling the tool API.","Never send formatted numbers (thousand separators, units, currency symbols).","Keep schema types in sync with what the client form actually produces."],"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"}