{"record":{"id":"781aef03dcf29fd3","repo":"iflytek/astron-agent","slug":"8306-toolbox-param-type-cannot-empty","errorCode":"8306","errorMessage":"toolbox.param.type.cannot.empty","messagePattern":"toolbox\\.param\\.type\\.cannot\\.empty","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":1485,"sourceCode":"        retObject.put(\"toolHttpHeaders\", toolHttpHeadersTarget);\n\n        JSONArray toolRequestBody = webSchemaObject.getJSONArray(\"toolRequestBody\");\n        JSONObject toolRequestBodyTarget = new JSONObject();\n        convertRequestParams(toolRequestBody, toolRequestBodyTarget);\n        retObject.put(\"toolRequestBody\", toolRequestBodyTarget);\n\n        return retObject;\n    }\n\n    private void convertRequestParams(JSONArray paramArray, JSONObject targetObject) {\n        if (CollectionUtils.isEmpty(paramArray)) {\n            return;\n        }\n        for (int i = 0; i < paramArray.size(); i++) {\n            JSONObject jsonObject = paramArray.getJSONObject(i);\n            String type = jsonObject.getString(\"type\");\n            if (StringUtils.isEmpty(type)) {\n                throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_TYPE_CANNOT_EMPTY);\n            }\n\n            String params = jsonObject.getString(\"title\");\n            if (STRING.equals(type) || NUMBER.equals(type) || BOOLEAN.equals(type)) {// Single attribute\n                Object defaultValue = jsonObject.get(\"default\");\n                targetObject.put(params, defaultValue);\n            } else if (OBJECT.equals(type) || ARRAY.equals(type)) {// Composite attribute object array\n                JSONArray jsonArray = jsonObject.getJSONArray(\"children\");\n                if (OBJECT.equals(type)) {\n                    JSONObject prop = new JSONObject();\n                    targetObject.put(params, prop);\n\n                    convertRequestParams(jsonArray, prop);\n                }\n            }\n        }\n    }\n","sourceCodeStart":1467,"sourceCodeEnd":1503,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1467-L1503","documentation":"Thrown by ToolBoxService during parameter-array processing when a parameter definition object has an empty or missing \"type\" field. Every parameter entry in the tool's parameter schema must declare one of the supported types (STRING/NUMBER/BOOLEAN, or complex types) so the service knows how to coerce defaults and validate inputs.","triggerScenarios":"Saving or importing a tool definition whose parameterArray contains an entry without a \"type\" key (or with an empty string), e.g. a hand-edited JSON schema or a tool created via API omitting the type field.","commonSituations":"Hand-authored JSON/YAML tool definitions missing a field; migration scripts that copy parameter objects but drop \"type\"; frontend form that allows saving with an unselected type dropdown.","solutions":["Add a valid \"type\" value (STRING, NUMBER, BOOLEAN, or an allowed complex type) to every entry in the parameter array.","Fix the producing code/form so the type dropdown cannot be left empty before submit.","Add a client-side check: fail fast if any parameter definition lacks a non-empty type.","Re-import the tool definition from a known-good template."],"exampleFix":"// before\n{\"title\": \"timeout\", \"default\": 30}\n// after\n{\"title\": \"timeout\", \"type\": \"NUMBER\", \"default\": 30}","handlingStrategy":"validation","validationCode":"for (JSONObject p : paramArray) {\n    if (p == null || p.getString(\"type\") == null || p.getString(\"type\").isBlank()) {\n        throw new IllegalArgumentException(\"Every parameter definition requires a non-empty 'type'\");\n    }\n}","typeGuard":"boolean hasType(JSONObject p) {\n    return p != null && p.getString(\"type\") != null && !p.getString(\"type\").isBlank();\n}","tryCatchPattern":"try {\n    toolBoxService.saveToolSchema(paramArray);\n} catch (BusinessException e) {\n    if (\"TOOLBOX_PARAM_TYPE_CANNOT_EMPTY\".equals(String.valueOf(e.getCode()))) {\n        // point user to the parameter entry missing 'type'\n    }\n}","preventionTips":["Enforce the type dropdown as a required field in the parameter form.","Validate tool-definition JSON against a schema before import/save.","Never hand-edit tool JSON without re-validating types afterwards."],"tags":["java","schema-validation","toolbox"],"backgroundTag":"empty-required-field","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"}