iflytek/astron-agent · error · BusinessException

8317

8317

Error message

toolbox.not.number.type

What it means

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.

Solutions

  1. Ignore the misleading 'number' wording: send true/false (or "true"/"false") for the BOOLEAN-typed parameter.
  2. Check the logged offending value to find the actual mismatched field.
  3. Align the tool schema with what callers actually send (declare STRING/OBJECT if needed).
  4. 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.

Example fix

// before (ToolBoxService.java, BOOLEAN case)
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);
// after
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_BOOLEAN_TYPE);
Defensive patterns

Strategy: try-catch

Validate before calling

for (var e : booleanParams.entrySet()) {
    Object v = e.getValue();
    boolean ok = v instanceof Boolean || (v instanceof String s && s.matches("(?i)true|false"));
    if (!ok) throw new IllegalArgumentException("Param " + e.getKey() + " must be boolean");
}

Type guard

boolean isBoolean(Object v) {
    return v instanceof Boolean
        || (v instanceof String s && s.trim().matches("(?i)true|false"));
}

Try / catch

try {
    toolBoxService.callTool(...);
} catch (BusinessException e) {
    // NOTE: code TOOLBOX_NOT_NUMBER_TYPE (8317) may actually mean a BOOLEAN
    // coercion failure at ToolBoxService.java:1439 — inspect boolean params too
}

Prevention

When it happens

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

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

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

Appendix: source

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

                            } catch (Exception e) {
                                log.error(value + " is not Number type");
                                throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);
                            }
                            break;
                        case INTEGER:
                            try {
                                jsonObject.put(item.getName(), 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 {
                                jsonObject.put(item.getName(), Boolean.valueOf(String.valueOf(value)));
                            } catch (Exception e) {
                                log.error(value + " is not Boolean type");
                                throw new BusinessException(ResponseEnum.TOOLBOX_NOT_NUMBER_TYPE);
                            }
                            break;
                        case STRING:
                        default:
                            jsonObject.put(item.getName(), item.getDft());
                    }
            }
        });
        return jsonObject;
    }

    private JSONObject convertWebSchemaTORequestJSON(JSONObject webSchemaObject) {
        JSONObject retObject = new JSONObject();
        // Input
        JSONArray toolUrlParams = webSchemaObject.getJSONArray("toolUrlParams");
        JSONObject toolUrlParamsTarget = new JSONObject();
        convertRequestParams(toolUrlParams, toolUrlParamsTarget);
        retObject.put("toolUrlParams", toolUrlParamsTarget);

View on GitHub (pinned to 5e758547a8)