{"record":{"id":"be2935d00497a26c","repo":"alibaba/spring-ai-alibaba","slug":"error-be2935","errorCode":null,"errorMessage":"数据项不存在: ","messagePattern":"数据项不存在: ","errorType":"exception","errorClass":"RuntimeException","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":169,"sourceCode":"\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);\n","sourceCodeStart":151,"sourceCodeEnd":187,"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#L151-L187","documentation":"Thrown by DatasetItemServiceImpl.deleteById() when datasetItemMapper.selectById(id) returns null, meaning no dataset item row with that id exists. The delete is aborted with a descriptive message instead of silently doing nothing.","triggerScenarios":"Calling deleteById(id) for an item already deleted, an id from another dataset/environment, or an id that never existed.","commonSituations":"Double-delete from duplicate UI clicks or retry logic; stale front-end list after another user removed the item; wrong database profile.","solutions":["Check the item exists before deleting (or handle the absence gracefully as idempotent delete)","Refresh the item list and use a current id","Confirm the service connects to the intended database/environment","If concurrent deletes are expected, catch this error and treat the item as already removed"],"exampleFix":"// before\ndatasetItemService.deleteById(itemId); // itemId already deleted\n// after\ntry {\n    datasetItemService.deleteById(itemId);\n} catch (RuntimeException e) {\n    // treat as idempotent success if item no longer exists\n}","handlingStrategy":"try-catch","validationCode":"if (id != null && datasetItemMapper.selectById(id) == null) { log.info(\"item {} already gone\", id); return; }","typeGuard":null,"tryCatchPattern":"try { service.deleteById(id); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"数据项不存在\")) { /* idempotent: already deleted */ } else { throw e; } }","preventionTips":["Design delete as idempotent on the client (404-like = success)","Refresh item lists before issuing deletes after user actions","Avoid double-submitting delete requests (disable button, debounce)"],"tags":["mybatis","delete","resource-not-found"],"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-14T05:17:10.506Z"}