{"record":{"id":"ea05c2ed107f3872","repo":"alibaba/spring-ai-alibaba","slug":"dataset-version-not-found","errorCode":null,"errorMessage":"Dataset version not found: ","messagePattern":"Dataset version not found: ","errorType":"exception","errorClass":"IllegalArgumentException","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/DatasetVersionServiceImpl.java","lineNumber":186,"sourceCode":"\n        return DatasetVersion.fromDO(versionDO);\n    }\n\n\n    /**\n     * Delete dataset version by ID\n     */\n    @Transactional\n    public void deleteById(Long id) {\n        log.info(\"Deleting dataset version: {}\", id);\n        \n        if (id == null) {\n            throw new IllegalArgumentException(\"Version ID cannot be null\");\n        }\n\n        DatasetVersionDO existingVersion = datasetVersionMapper.selectById(id);\n        if (existingVersion == null) {\n            throw new IllegalArgumentException(\"Dataset version not found: \" + id);\n        }\n\n        if (\"PUBLISHED\".equals(existingVersion.getStatus())) {\n            throw new IllegalStateException(\"Cannot delete published version: \" + id);\n        }\n\n        int result = datasetVersionMapper.deleteById(id);\n        if (result <= 0) {\n            throw new RuntimeException(\"Failed to delete dataset version\");\n        }\n\n        log.info(\"Dataset version deleted successfully: {}\", id);\n    }\n\n    @Override\n    public PageResult<Experiment> getExperiments(DatasetExperimentsListRequest request) {\n        long offset = (request.getPageNumber() - 1L) * request.getPageSize();\n","sourceCodeStart":168,"sourceCodeEnd":204,"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/DatasetVersionServiceImpl.java#L168-L204","documentation":"deleteById() looks up the version first and throws IllegalArgumentException(\"Dataset version not found: \" + id) when selectById returns null. The deletion targets a primary key that does not exist, so the service refuses instead of issuing a silent no-op delete.","triggerScenarios":"DELETE request with an id not present in the dataset_version table; the row was already deleted by another request/user; the ID belongs to a different environment or database.","commonSituations":"Double-clicking a delete button so the second request hits an already-deleted row; stale UI lists after someone else deleted the version; seed/test data IDs hardcoded from another schema.","solutions":["Confirm the version ID exists (call getById) before deleting.","Treat this as idempotent success in the caller if the goal is 'ensure deleted'.","Refresh the version list in the UI before issuing deletes to avoid stale IDs."],"exampleFix":"// before\nservice.deleteById(id); // throws if already gone\n// after\nif (service.getById(id) != null) {\n    service.deleteById(id);\n}","handlingStrategy":"validation","validationCode":"if (service.getById(id) == null) {\n    return ResponseEntity.notFound().build(); // skip delete\n}","typeGuard":null,"tryCatchPattern":"try {\n    service.deleteById(id);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Dataset version not found\")) {\n        // treat as idempotent success or 404\n    } else { throw e; }\n}","preventionTips":["Check existence before deleting; treat repeated deletes as idempotent.","Refresh UI lists after any deletion to drop stale IDs.","Catch IllegalArgumentException and inspect the message prefix to distinguish not-found from null-id."],"tags":["record-not-found","delete","dataset-version","illegal-argument"],"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"}