{"record":{"id":"ae1745604540fa92","repo":"alibaba/spring-ai-alibaba","slug":"error-ae1745","errorCode":null,"errorMessage":"尝试删除不存在的数据项: {}","messagePattern":"尝试删除不存在的数据项: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/DatasetItemServiceImpl.java","lineNumber":168,"sourceCode":"        datasetItemMapper.update(request.getId(),request.getDataContent());\n\n        return getById(request.getId());\n    }\n\n    @Override\n\n    public void deleteById(Long id) {\n        log.info(\"删除数据项: {}\", id);\n        \n        // 数据验证\n        if (id == null || id <= 0) {\n            throw new IllegalArgumentException(\"数据项ID不能为空且必须大于0\");\n        }\n        \n        // 检查数据项是否存在\n        DatasetItemDO existingItem = datasetItemMapper.selectById(id);\n        if (existingItem == null) {\n            log.warn(\"尝试删除不存在的数据项: {}\", id);\n            throw new RuntimeException(\"数据项不存在: \" + id);\n        }\n        \n\n        int result = datasetItemMapper.deleteById(id);\n        if (result <= 0) {\n            log.error(\"数据项删除失败: {}\", id);\n            throw new RuntimeException(\"数据项删除失败: \" + id);\n        }\n        \n        log.info(\"数据项删除成功: {}\", id);\n    }\n\n    @Override\n    public void batchDelete(List<Long> ids) {\n        log.info(\"批量删除数据项: {}\", JSONObject.toJSONString(ids));\n\n        datasetItemMapper.batchDeleteByIds(ids);","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/DatasetItemServiceImpl.java#L150-L186","documentation":"DatasetItemServiceImpl.deleteById verifies the item exists and throws RuntimeException('数据项不存在: <id>') when it doesn't, after logging '尝试删除不存在的数据项'. This is a hard failure surfaced to the caller as an unchecked exception.","triggerScenarios":"deleteById(id) with a positive, non-null id that has no row in the dataset item table — item already deleted, wrong id, or cross-environment id.","commonSituations":"Double-delete from retries or UI double-click; stale list data in the frontend; deleting by id from another dataset.","solutions":["Handle or avoid the duplicate delete: make the client tolerate 'not found' (idempotent delete) or check existence first","Refresh the frontend list after deletes so stale ids are not resubmitted","Catch the RuntimeException in the controller and map it to a 404 response","Verify the id against the correct database/environment"],"exampleFix":"// before\nservice.deleteById(itemId); // throws on second call\n// after\ntry { service.deleteById(itemId); }\ncatch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"数据项不存在\")) { /* already deleted, ok */ }\n    else throw e;\n}","handlingStrategy":"try-catch","validationCode":"DatasetItemDO item = datasetItemMapper.selectById(id);\nif (item == null) { /* skip delete or warn: already gone */ }","typeGuard":"boolean itemExists(Long id) { return id != null && id > 0 && datasetItemMapper.selectById(id) != null; }","tryCatchPattern":"try { service.deleteById(id); }\ncatch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"数据项不存在\")) { log.info(\"item {} already deleted\", id); }\n    else throw e;\n}","preventionTips":["Make delete idempotent on the client (ignore already-deleted)","Debounce/double-click guard on delete buttons in the UI","Verify ids against the current environment before deleting"],"tags":["database","delete","dataset","runtime-exception"],"backgroundTag":"record-not-found","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}