{"record":{"id":"3faf7b7a67fa2f49","repo":"iflytek/astron-agent","slug":"toolbox-not-exist-modify","errorCode":"TOOLBOX_NOT_EXIST_MODIFY","errorMessage":"BusinessException(ResponseEnum.TOOLBOX_NOT_EXIST_MODIFY)","messagePattern":"BusinessException\\(ResponseEnum\\.TOOLBOX_NOT_EXIST_MODIFY\\)","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":169,"sourceCode":"\n    private static final String FAVORITE_KEY_PREFIX = \"new:user:favorite:tool:\";\n\n    private static final String CONFIG_KEY_PREFIX = \"spark_bot:tool_config:\";\n    private static final String TOOL_HEAT_VALUE_PREFIX = \"spark_bot:tool:heat_value:\";\n\n\n\n    @Transactional\n    public ToolBox createTool(ToolBoxDto toolBoxDto) {\n\n        ToolBox toolBox;\n        if (toolBoxDto.getId() != null) {\n            toolBox = getById(toolBoxDto.getId());\n            if (toolBox != null) {\n                // Add permission validation\n                dataPermissionCheckTool.checkToolBelong(toolBox);\n            } else {\n                throw new BusinessException(ResponseEnum.TOOLBOX_NOT_EXIST_MODIFY);\n            }\n        } else {\n            toolBox = new ToolBox();\n        }\n        // Validate the endpoint submitted in this request before it is copied to the entity or sent\n        // to the tool service. Validating the existing entity would miss new and changed endpoints.\n        if (StringUtils.isNotBlank(toolBoxDto.getEndPoint())) {\n            urlCheckTool.checkUrl(toolBoxDto.getEndPoint());\n        }\n        toolBoxDto.setVersion(\"V1.0\");\n        String schemaString = buildToolBox(toolBox, toolBoxDto);\n        ToolProtocolDto toolProtocolDto = buildToolRequest(toolBoxDto, schemaString);\n        ToolResp toolCreateResp = toolServiceCallHandler.toolCreate(toolProtocolDto);\n        toolServiceCallHandler.dealResult(toolCreateResp);\n        String toolId = ((JSONObject) toolCreateResp.getData()).getJSONArray(\"tools\").getObject(0, Tool.class).getId();\n        toolBox.setToolId(toolId);\n        // Clear temporary data\n        toolBox.setTemporaryData(StringUtils.EMPTY);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L151-L187","documentation":"createTool throws BusinessException(TOOLBOX_NOT_EXIST_MODIFY) when the DTO carries an id but no matching ToolBox record exists (after permission checks). It means the client attempted to modify/update a toolbox tool that is not in the database.","triggerScenarios":"Submitting createTool with an id that no longer exists in the tool box table (upsert-style call where the id is stale).","commonSituations":"Concurrent deletion by another user before the update lands; frontend caching an old tool id after the tool was removed; copying a payload with an id from another environment/tenant.","solutions":["Confirm the tool id exists (getById / list tools) before sending it in the DTO.","Omit id (send null) to create a new tool instead of updating.","Refresh the tool list in the UI and retry with a valid id.","Catch TOOLBOX_NOT_EXIST_MODIFY and prompt the user that the tool was removed."],"exampleFix":"// before\ndto.setId(123L); // tool 123 was deleted\nservice.createTool(dto); // throws\n// after\nif (toolBoxService.getById(123L) == null) dto.setId(null); // create new\nservice.createTool(dto);","handlingStrategy":"validation","validationCode":"if (dto.getId() != null && toolBoxService.getById(dto.getId()) == null) { dto.setId(null); /* or abort */ }","typeGuard":"boolean toolExists(Long id) { return id == null || toolBoxService.getById(id) != null; }","tryCatchPattern":"try { service.createTool(dto); } catch (BusinessException e) { if (ResponseEnum.TOOLBOX_NOT_EXIST_MODIFY.equals(e.getCode())) { refreshToolList(); notifyToolDeleted(dto.getId()); } else { throw e; } }","preventionTips":["Use a dedicated update endpoint instead of id-based upsert semantics.","Refresh tool lists before editing so ids are current.","Handle concurrent deletes with optimistic locking or re-check on submit.","Clear cached tool ids after any delete operation."],"tags":["entity-not-found","update","toolbox","java"],"backgroundTag":"entity-not-found","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"}