{"record":{"id":"19183ceff1904ade","repo":"iflytek/astron-agent","slug":"toolbox-not-integer-type","errorCode":"TOOLBOX_NOT_INTEGER_TYPE","errorMessage":"BusinessException(ResponseEnum.TOOLBOX_NOT_INTEGER_TYPE)","messagePattern":"BusinessException\\(ResponseEnum\\.TOOLBOX_NOT_INTEGER_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":1396,"sourceCode":"                            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;\n                                case STRING:\n                                default:\n                                    array.add(value);\n                            }\n                        }\n                    }\n                    jsonObject.put(item.getName(), array);\n                    break;","sourceCodeStart":1378,"sourceCodeEnd":1414,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1378-L1414","documentation":"Thrown by ToolBoxService when converting an array element whose declared parameter type is INTEGER: Long.valueOf(String.valueOf(value)) failed because the value string is not a valid 64-bit integer. The service rejects fractional or non-numeric strings for INTEGER-typed inputs.","triggerScenarios":"Calling a toolbox tool whose schema declares an array item of type INTEGER while the caller supplies \"3.14\", \"1e5\", \"\", null, or any string Long.parseLong cannot parse.","commonSituations":"Callers send floats where integers are declared (e.g. 2.0 as \"2.0\" string form fails Long.valueOf); scientific-notation numbers from computed fields; UI sending empty strings for untouched integer inputs.","solutions":["Ensure INTEGER array elements are whole numbers with no decimal point or exponent (send 2, not 2.0 or 2e0).","Convert fractions to whole numbers or change the declared schema type to NUMBER if decimals are expected.","Validate the value with a regex like ^-?\\d+$ before calling the tool.","Check the error log for the offending value to find which parameter is malformed."],"exampleFix":"// before\n{\"items\": [\"2.0\", \"3\"]}\n// after\n{\"items\": [2, 3]}","handlingStrategy":"validation","validationCode":"boolean isInteger(Object v) {\n    if (v == null) return false;\n    String s = String.valueOf(v).trim();\n    return s.matches(\"-?\\\\d+\") && s.length() <= 19;\n}\n// reject fractions like \"2.0\" before the call","typeGuard":"boolean isLongString(Object v) {\n    if (v instanceof Long || v instanceof Integer) return true;\n    if (v instanceof Double d) return d == Math.floor(d) && !d.isInfinite();\n    return v instanceof String s && s.trim().matches(\"-?\\\\d+\");\n}","tryCatchPattern":"try {\n    toolBoxService.callTool(...);\n} catch (BusinessException e) {\n    if (\"TOOLBOX_NOT_INTEGER_TYPE\".equals(e.getCode())) {\n        // log offending element, coerce or reject\n    }\n}","preventionTips":["Send whole numbers only for INTEGER fields — not 2.0 or 2e0.","Round fractional values explicitly before sending.","Use the JSON number type, not strings, when the API accepts numbers."],"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"}