iflytek/astron-agent · error · BusinessException

TOOLBOX_NOT_INTEGER_TYPE

TOOLBOX_NOT_INTEGER_TYPE

Error message

BusinessException(ResponseEnum.TOOLBOX_NOT_INTEGER_TYPE)

What it means

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.

Solutions

  1. Ensure INTEGER array elements are whole numbers with no decimal point or exponent (send 2, not 2.0 or 2e0).
  2. Convert fractions to whole numbers or change the declared schema type to NUMBER if decimals are expected.
  3. Validate the value with a regex like ^-?\d+$ before calling the tool.
  4. Check the error log for the offending value to find which parameter is malformed.

Example fix

// before
{"items": ["2.0", "3"]}
// after
{"items": [2, 3]}
Defensive patterns

Strategy: validation

Validate before calling

boolean isInteger(Object v) {
    if (v == null) return false;
    String s = String.valueOf(v).trim();
    return s.matches("-?\\d+") && s.length() <= 19;
}
// reject fractions like "2.0" before the call

Type guard

boolean isLongString(Object v) {
    if (v instanceof Long || v instanceof Integer) return true;
    if (v instanceof Double d) return d == Math.floor(d) && !d.isInfinite();
    return v instanceof String s && s.trim().matches("-?\\d+");
}

Try / catch

try {
    toolBoxService.callTool(...);
} catch (BusinessException e) {
    if ("TOOLBOX_NOT_INTEGER_TYPE".equals(e.getCode())) {
        // log offending element, coerce or reject
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/19183ceff1904ade. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:1396

                            JSONObject objItem = recurGenRunParam(childItem.getChildren());
                            array.add(objItem);
                        } else {
                            Object value = childItem.getDft();
                            switch (childItem.getType()) {
                                case NUMBER:
                                    try {
                                        array.add(Double.valueOf(String.valueOf(value)));
                                    } 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;

View on GitHub (pinned to 5e758547a8)