alibaba/spring-ai-alibaba · error · IllegalArgumentException
Dataset version not found:
Error message
Dataset version not found:
What it means
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.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/DatasetVersionServiceImpl.java:186
return DatasetVersion.fromDO(versionDO);
}
/**
* Delete dataset version by ID
*/
@Transactional
public void deleteById(Long id) {
log.info("Deleting dataset version: {}", id);
if (id == null) {
throw new IllegalArgumentException("Version ID cannot be null");
}
DatasetVersionDO existingVersion = datasetVersionMapper.selectById(id);
if (existingVersion == null) {
throw new IllegalArgumentException("Dataset version not found: " + id);
}
if ("PUBLISHED".equals(existingVersion.getStatus())) {
throw new IllegalStateException("Cannot delete published version: " + id);
}
int result = datasetVersionMapper.deleteById(id);
if (result <= 0) {
throw new RuntimeException("Failed to delete dataset version");
}
log.info("Dataset version deleted successfully: {}", id);
}
@Override
public PageResult<Experiment> getExperiments(DatasetExperimentsListRequest request) {
long offset = (request.getPageNumber() - 1L) * request.getPageSize();
View on GitHub (pinned to f82da0b50f)
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.
Example fix
// before
service.deleteById(id); // throws if already gone
// after
if (service.getById(id) != null) {
service.deleteById(id);
} Defensive patterns
Strategy: validation
Validate before calling
if (service.getById(id) == null) {
return ResponseEntity.notFound().build(); // skip delete
} Try / catch
try {
service.deleteById(id);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Dataset version not found")) {
// treat as idempotent success or 404
} else { throw e; }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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
- Version ID cannot be null
- Failed to update dataset version
- Cannot delete published version:
- Tool not found with id: <id>
- Unknown agent status code:
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/ea05c2ed107f3872.
Report an issue: GitHub.