alibaba/spring-ai-alibaba · error · RuntimeException
Failed to update dataset version
Error message
Failed to update dataset version
What it means
update() calls datasetVersionMapper.updateById(...) and throws a generic RuntimeException when the affected-row count is <= 0. This means the UPDATE statement matched no rows — almost always because no dataset version exists with the given ID. It is the service's way of surfacing a no-op database update as a failure.
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:142
// Validate request
if (request.getDatasetVersionId() == null) {
throw new IllegalArgumentException("Version ID cannot be null");
}
// Note: Version number updates are not supported in this implementation
// to maintain data integrity and prevent conflicts
// Update fields - only update available fields
int result = datasetVersionMapper.update(
request.getDatasetVersionId(),
request.getDescription(),
request.getStatus()
);
if (result <= 0) {
throw new RuntimeException("Failed to update dataset version");
}
// Get updated version
DatasetVersionDO updatedVersionDO = datasetVersionMapper.selectById(request.getDatasetVersionId());
DatasetVersion updatedVersion = DatasetVersion.fromDO(updatedVersionDO);
log.info("Dataset version updated successfully: {}", updatedVersion);
return updatedVersion;
}
/**
* Get dataset version by ID
*/
public DatasetVersion getById(Long id) {
log.info("Getting dataset version by ID: {}", id);
if (id == null) {
throw new IllegalArgumentException("Version ID cannot be null");View on GitHub (pinned to f82da0b50f)
Solutions
- Verify the version exists first: datasetVersionMapper.selectById(id) or call service.getById(id) and check for null.
- Re-fetch the current version list and retry with a valid datasetVersionId.
- Prefer throwing a descriptive entity-not-found exception instead of a generic RuntimeException so callers can distinguish 'not found' from 'DB failure'.
Example fix
// before
service.update(requestWithId999); // id not present -> RuntimeException
// after
if (service.getById(id) != null) {
service.update(request);
} Defensive patterns
Strategy: validation
Validate before calling
DatasetVersion existing = service.getById(request.getDatasetVersionId());
if (existing == null) {
throw new IllegalStateException("Version " + request.getDatasetVersionId() + " does not exist");
} Try / catch
try {
return service.update(request);
} catch (RuntimeException e) {
if (service.getById(request.getDatasetVersionId()) == null) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "dataset version not found");
}
throw e;
} Prevention
- Check existence with getById before updating.
- Refresh stale lists before edit operations to avoid deleted IDs.
- Distinguish environments; never reuse IDs across test/prod databases.
When it happens
Trigger: Calling update() with a datasetVersionId that does not exist in the table; a concurrent transaction deleted the row between validation and update; the mapper's update SQL filters by status/version in a way that skips the row.
Common situations: Stale client caches referencing versions deleted elsewhere; wrong-ID copy/paste across environments (test vs prod database); optimistic concurrency where another user deleted the version first.
Related errors
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/543d89f08750acf6.
Report an issue: GitHub.