{"record":{"id":"b3f5f3166ee2f203","repo":"iflytek/astron-agent","slug":"8309-toolbox-param-get-source-illegal","errorCode":"8309","errorMessage":"toolbox.param.get.source.illegal","messagePattern":"toolbox\\.param\\.get\\.source\\.illegal","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":1628,"sourceCode":"            validateFromValue(from);\n        }\n\n        boolean required = jsonObject.getBooleanValue(\"required\");\n        JSONObject paramObject = createBaseParamObject(title, description, type);\n\n        if (input) {\n            addInputSpecificFields(paramObject, from, required, jsonObject);\n        }\n\n        targetObject.put(params, paramObject);\n    }\n\n    /**\n     * Validate from field value\n     */\n    private void validateFromValue(Integer from) {\n        if (from == null || (from != 0 && from != 1 && from != 2)) {\n            throw new BusinessException(ResponseEnum.TOOLBOX_PARAM_GET_SOURCE_ILLEGAL);\n        }\n    }\n\n    /**\n     * Create base parameter object\n     */\n    private JSONObject createBaseParamObject(String title, String description, String type) {\n        JSONObject paramObject = new JSONObject();\n        paramObject.put(\"title\", title);\n        paramObject.put(\"description\", description);\n        paramObject.put(\"type\", type);\n        return paramObject;\n    }\n\n    /**\n     * Add input specific fields\n     */\n    private void addInputSpecificFields(JSONObject paramObject, Integer from, boolean required, JSONObject jsonObject) {","sourceCodeStart":1610,"sourceCodeEnd":1646,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L1610-L1646","documentation":"validateFromValue enforces that the 'from' field of a tool parameter (its value source) is exactly 0, 1, or 2. A null value or any other integer is rejected with TOOLBOX_PARAM_GET_SOURCE_ILLEGAL (code 8309). This is an enum-style whitelist check on the parameter's source type.","triggerScenarios":"Submitting a tool parameter definition where the \"from\" field is missing (null) or set to a value outside {0,1,2}, e.g. 3, -1, or 100.","commonSituations":"Client code using stale or wrong enum constants after the source-type list changed; hand-written JSON payloads guessing the value; UI sending uninitialized dropdown state (null) when the user never picked a source.","solutions":["Set \"from\" to one of the allowed values 0, 1, or 2 in the request payload","Update the client/UI to default the source selector to a valid value instead of null","Sync client enum definitions with the server's current from-value contract"],"exampleFix":"// before\n{\"paramName\":\"city\",\"description\":\"City name\",\"from\":5}\n// after\n{\"paramName\":\"city\",\"description\":\"City name\",\"from\":0}","handlingStrategy":"validation","validationCode":"Integer from = payload.getFrom(); if (from == null || (from != 0 && from != 1 && from != 2)) { throw new IllegalArgumentException(\"from must be 0, 1 or 2\"); }","typeGuard":"boolean isValidFrom(Integer from) { return from != null && (from == 0 || from == 1 || from == 2); }","tryCatchPattern":"try { toolboxApi.saveParam(payload); } catch (BusinessException e) { if (e.getCode() == 8309) { /* map to 400 with allowed values */ } else throw e; }","preventionTips":["Model 'from' as an enum (0/1/2) in client code instead of raw integers","Default the source selector in the UI to a valid value","Share a single enum definition between client and server"],"tags":["java","spring-boot","validation","enum","toolbox"],"backgroundTag":"invalid-enum-value","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"}