iflytek/astron-agent · error · BusinessException
TOOLBOX_NOT_EXIST_DELETE
TOOLBOX_NOT_EXIST_DELETE
Error message
BusinessException(ResponseEnum.TOOLBOX_NOT_EXIST_DELETE)
What it means
ToolBoxService.deleteTool throws TOOLBOX_NOT_EXIST_DELETE when getById(id) finds no ToolBox for the given id. Deletion is aborted before any permission check or soft-delete. The distinct code (vs TOOLBOX_NOT_EXIST) marks the failure as coming from the delete operation.
Solutions
- Confirm the tool id exists via getDetail or the tool list before deleting.
- Treat this error as idempotent success if the goal is 'tool is gone' — refresh the list.
- Check tenant/space context: the tool may exist under a different space.
- Fix clients to remove the item from the list after a successful delete to avoid duplicate delete calls.
Example fix
// before
toolBoxService.deleteTool(id); // throws if already deleted
// after
try {
toolBoxService.deleteTool(id);
} catch (BusinessException e) {
// treat TOOLBOX_NOT_EXIST_DELETE as already-deleted; tolerate idempotent delete
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean exists = toolBoxService.getById(id) != null;
if (exists) { toolBoxService.deleteTool(id); } Try / catch
try {
toolBoxService.deleteTool(id);
} catch (BusinessException e) {
if ("TOOLBOX_NOT_EXIST_DELETE".equals(e.getCode())) {
// already deleted; treat as idempotent success
}
} Prevention
- Remove items from UI lists immediately after successful delete to prevent duplicate calls.
- Guard against double-click on delete buttons (disable after first click).
- Verify tool existence before issuing delete in scripts.
When it happens
Trigger: Calling the tool delete API with a nonexistent id; deleting an already-deleted (soft-deleted, deleted=true) tool; id from a stale UI list after another user removed the tool; id belonging to a different tenant/space.
Common situations: Double-click delete causing second call to hit an already-deleted row; automated cleanup scripts using outdated inventories; cross-environment id reuse (dev ids used in prod).
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/5a33e90814baaeaf.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:428
try {
Object valueA = field.get(a);
Object valueB = field.get(b);
if (!Objects.equals(valueA, valueB)) {
return false;
}
} catch (IllegalAccessException e) {
throw new RuntimeException("Failed to compare field: " + field.getName(), e);
}
}
return true;
}
@Transactional
public Object deleteTool(Long id) {
ToolBox toolBox = getById(id);
if (toolBox == null) {
throw new BusinessException(ResponseEnum.TOOLBOX_NOT_EXIST_DELETE);
}
dataPermissionCheckTool.checkToolBelong(toolBox);
// Delete draft tools directly
if (toolBox.getStatus().equals(0)) {
toolBox.setDeleted(true);
toolBox.setUpdateTime(new Timestamp(System.currentTimeMillis()));
updateById(toolBox);
return ApiResult.success();
}
long flowListCount = flowToolRelMapper.selectCount(Wrappers.lambdaQuery(FlowToolRel.class).eq(FlowToolRel::getToolId, toolBox.getToolId()));
if (flowListCount > 0) {
throw new BusinessException(ResponseEnum.TOOLBOX_CANNOT_DELETE_RELATED_WORKFLOW);
}
long modelListCount = botToolRelService.count(Wrappers.lambdaQuery(BotToolRel.class).eq(BotToolRel::getToolId, toolBox.getToolId()));
if (modelListCount > 0) {
throw new BusinessException(ResponseEnum.TOOLBOX_CANNOT_DELETE_RELATED);View on GitHub (pinned to 5e758547a8)