{"record":{"id":"9b907350b67e5fe6","repo":"iflytek/astron-agent","slug":"8307-toolbox-param-cannot-empty","errorCode":"8307","errorMessage":"toolbox.param.cannot.empty","messagePattern":"toolbox\\.param\\.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":1574,"sourceCode":"        String title = jsonObject.getString(\"paramName\");\n        String description = jsonObject.getString(\"description\");\n\n        if (isSimpleType(type)) {\n            processSimpleTypeParam(jsonObject, targetObject, params, title, description, type, input);\n        } else if (isComplexType(type)) {\n            processComplexTypeParam(jsonObject, targetObject, previewType, params, title, description, type, input);\n        } else {\n            throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_TYPE_NOT_MATCH);\n        }\n    }\n\n    /**\n     * Validate parameter basic information\n     */\n    private void validateParamBasicInfo(JSONObject jsonObject, Integer previewType) {\n        String type = jsonObject.getString(\"type\");\n        if (StringUtils.isEmpty(type)) {\n            throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_CANNOT_EMPTY);\n        }\n\n        String params = jsonObject.getString(\"title\");\n        if (previewType == 0 && StringUtils.isEmpty(params)) {\n            throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_CANNOT_EMPTY);\n        }\n\n        String title = jsonObject.getString(\"paramName\");\n        String description = jsonObject.getString(\"description\");\n        if (StringUtils.isEmpty(title) || StringUtils.isEmpty(description)) {\n            throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_AND_DESC_CANNOT_EMPTY);\n        }\n    }\n\n    /**\n     * Determine if it is a simple type\n     */\n    private boolean isSimpleType(String type) {","sourceCodeStart":1556,"sourceCodeEnd":1592,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1556-L1592","documentation":"Thrown by ToolBoxService.validateParamBasicInfo when a parameter definition is missing its \"type\" (first check) or, when previewType == 0, the \"title\"/display name is empty. Both conditions surface the same TOOLBOX_PARAM_CANNOT_EMPTY error, enforcing that every parameter has at least a type and a title.","triggerScenarios":"Saving a tool with a parameter entry lacking the \"type\" key, or submitting for non-preview (previewType == 0, i.e. real save) a parameter whose \"title\" field is empty — both throw code 8307.","commonSituations":"Frontend form allowing 'add parameter' with blank fields; dynamically generated parameter rows where the user skipped the name; programmatic schema generation producing entries with null fields.","solutions":["Fill in the parameter \"type\" (and, for real saves, the \"title\") for every parameter entry before submitting.","Add client-side required-field validation on the parameter form (type and name are mandatory).","If this occurs during preview-only flows, verify previewType is set correctly — the title is only required when previewType == 0.","Filter out blank/placeholder parameter rows generated by the UI before sending the schema."],"exampleFix":"// before\n{\"title\": \"timeout\", \"type\": \"\"}\n// after\n{\"title\": \"timeout\", \"type\": \"NUMBER\"}","handlingStrategy":"validation","validationCode":"for (JSONObject p : paramArray) {\n    boolean missingType = p.getString(\"type\") == null || p.getString(\"type\").isBlank();\n    boolean missingTitle = previewType == 0 && (p.getString(\"title\") == null || p.getString(\"title\").isBlank());\n    if (missingType || missingTitle) throw new IllegalArgumentException(\"Parameter needs a type\" + (previewType == 0 ? \" and a title\" : \"\"));\n}","typeGuard":"boolean hasBasicInfo(JSONObject p, int previewType) {\n    String t = p.getString(\"type\"), title = p.getString(\"title\");\n    boolean typeOk = t != null && !t.isBlank();\n    boolean titleOk = previewType != 0 || (title != null && !title.isBlank());\n    return typeOk && titleOk;\n}","tryCatchPattern":"try {\n    toolBoxService.saveToolSchema(paramArray);\n} catch (BusinessException e) {\n    if (\"TOOLBOX_PARAM_CANNOT_EMPTY\".equals(String.valueOf(e.getCode()))) {\n        // highlight the first parameter row with an empty type (or title when saving)\n    }\n}","preventionTips":["Mark type and name fields required in the parameter editor UI.","Drop empty auto-added parameter rows before submit.","Pass previewType correctly — title is only mandatory for real saves (previewType == 0)."],"tags":["java","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-19T12:17:13.211Z"}