alibaba/spring-ai-alibaba · error · IllegalArgumentException
Version ID cannot be null
Error message
Version ID cannot be null
What it means
DatasetVersionServiceImpl.update() validates the request before applying changes. Since updates are keyed by datasetVersionId, a null ID makes the update meaningless, so an IllegalArgumentException is thrown up front instead of issuing a doomed database update. It is a guard against a malformed request body.
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:127
PageResult<DatasetVersion> result = new PageResult<>();
result.setTotalCount((long) totalCount);
result.setTotalPage(totalPages);
result.setPageNumber((long) request.getPageNumber());
result.setPageSize((long) request.getPageSize());
result.setPageItems(datasetVersions);
log.info("Dataset version list query completed, total: {}, current page: {}", totalCount, request.getPageNumber());
return result;
}
@Override
@Transactional
public DatasetVersion update(DatasetVersionUpdateRequest request) {
log.info("Updating dataset version: {}", request);
// 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 versionView on GitHub (pinned to f82da0b50f)
Solutions
- Set request.setDatasetVersionId(...) with the existing version's ID before calling update.
- Fix the JSON payload so the field is named datasetVersionId and is non-null.
- Add a @NotNull / Bean Validation annotation on DatasetVersionUpdateRequest.datasetVersionId so Spring rejects bad payloads with 400 before reaching the service.
Example fix
// before
DatasetVersionUpdateRequest req = new DatasetVersionUpdateRequest();
req.setDescription("v2 notes");
service.update(req); // throws
// after
req.setDatasetVersionId(42L);
service.update(req); Defensive patterns
Strategy: validation
Validate before calling
if (request == null || request.getDatasetVersionId() == null) {
throw new IllegalArgumentException("datasetVersionId is required for update");
} Type guard
boolean hasId(DatasetVersionUpdateRequest r) { return r != null && r.getDatasetVersionId() != null; } Try / catch
try {
service.update(request);
} catch (IllegalArgumentException e) {
return ResponseEntity.badRequest().body(Map.of("error", e.getMessage()));
} Prevention
- Always load the version (getById) before constructing the update request.
- Use Bean Validation @NotNull on DatasetVersionUpdateRequest.datasetVersionId.
- In API clients, send the exact field name datasetVersionId in JSON payloads.
When it happens
Trigger: Calling update(DatasetVersionUpdateRequest) via the service or its REST endpoint with a request whose datasetVersionId field is null (e.g. omitted in JSON payload, or constructed programmatically without setting the ID).
Common situations: Clients POST/PUT a JSON body with only description/status fields forgetting the id; deserialization leaves the field null because the JSON key is misspelled (e.g. versionId instead of datasetVersionId); new-request objects reused for create instead of update.
Related errors
- ${type} requires valid configuration
- Dataset version not found:
- 模型配置不能为空
- Configuration cannot be null
- maxDelay must be greater than or equal to 0.
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/a821878f5ae7fc13.
Report an issue: GitHub.