alibaba/spring-ai-alibaba · warning

Dataset version not found: {}

Error message

Dataset version not found: {}

What it means

This is a warning logged by DatasetVersionServiceImpl.getById when no dataset version row exists for the given ID in the database. It is not a thrown exception: the method returns null after logging, so callers must null-check the result. The framework logs a warning instead of throwing because a missing version ID is treated as an expected lookup miss.

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:165

        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");
        }

        DatasetVersionDO versionDO = datasetVersionMapper.selectById(id);
        if (versionDO == null) {
            log.warn("Dataset version not found: {}", id);
            return null;
        }

        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");
        }

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Verify the ID exists by querying the dataset_version table before calling getById.
  2. Null-check the return value and surface a 404-style response to the caller instead of proceeding.
  3. Confirm you are pointed at the correct database/environment (check datasource config).
  4. Ensure the version was not deleted by a cleanup job; re-create or select a valid version.

Example fix

// before
DatasetVersion version = datasetVersionService.getById(id);
String name = version.getName(); // NPE when not found

// after
DatasetVersion version = datasetVersionService.getById(id);
if (version == null) {
    throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Dataset version not found: " + id);
}
Defensive patterns

Strategy: type-guard

Validate before calling

public static boolean datasetVersionExists(Long id) {
    return id != null && datasetVersionMapper.selectById(id) != null;
}

Type guard

DatasetVersion v = datasetVersionService.getById(id);
if (v == null) {
    throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Dataset version not found: " + id);
}
// v is non-null from here

Prevention

When it happens

Trigger: Calling datasetVersionService.getById(id) with an ID that does not exist in the dataset_version table, or with an ID of a version that was deleted.

Common situations: A client passes a stale datasetVersionId after the version was deleted; a UI bookmark points at a purged version; a test uses a fabricated ID without seeding the database; cross-environment data (dev ID used against prod DB).

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/c4e6ac85c0d0f78e. Report an issue: GitHub.