{"record":{"id":"c4e6ac85c0d0f78e","repo":"alibaba/spring-ai-alibaba","slug":"dataset-version-not-found-c4e6ac","errorCode":null,"errorMessage":"Dataset version not found: {}","messagePattern":"Dataset version not found: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","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":165,"sourceCode":"        DatasetVersion updatedVersion = DatasetVersion.fromDO(updatedVersionDO);\n        log.info(\"Dataset version updated successfully: {}\", updatedVersion);\n        return updatedVersion;\n    }\n\n\n    /**\n     * Get dataset version by ID\n     */\n    public DatasetVersion getById(Long id) {\n        log.info(\"Getting dataset version by ID: {}\", id);\n        \n        if (id == null) {\n            throw new IllegalArgumentException(\"Version ID cannot be null\");\n        }\n\n        DatasetVersionDO versionDO = datasetVersionMapper.selectById(id);\n        if (versionDO == null) {\n            log.warn(\"Dataset version not found: {}\", id);\n            return null;\n        }\n\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","sourceCodeStart":147,"sourceCodeEnd":183,"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#L147-L183","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Verify the ID exists by querying the dataset_version table before calling getById.","Null-check the return value and surface a 404-style response to the caller instead of proceeding.","Confirm you are pointed at the correct database/environment (check datasource config).","Ensure the version was not deleted by a cleanup job; re-create or select a valid version."],"exampleFix":"// before\nDatasetVersion version = datasetVersionService.getById(id);\nString name = version.getName(); // NPE when not found\n\n// after\nDatasetVersion version = datasetVersionService.getById(id);\nif (version == null) {\n    throw new ResponseStatusException(HttpStatus.NOT_FOUND, \"Dataset version not found: \" + id);\n}","handlingStrategy":"type-guard","validationCode":"public static boolean datasetVersionExists(Long id) {\n    return id != null && datasetVersionMapper.selectById(id) != null;\n}","typeGuard":"DatasetVersion v = datasetVersionService.getById(id);\nif (v == null) {\n    throw new ResponseStatusException(HttpStatus.NOT_FOUND, \"Dataset version not found: \" + id);\n}\n// v is non-null from here","tryCatchPattern":null,"preventionTips":["Always null-check the result of getById-style service methods — they return null instead of throwing.","Validate IDs against the database before detail lookups.","Pin environment-specific IDs; never reuse IDs across dev/staging/prod.","Enable referential-integrity checks in tests seeding dataset versions."],"tags":["java","spring","mybatis","dataset","null-return"],"backgroundTag":"entity-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"}