{"record":{"id":"543d89f08750acf6","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-update-dataset-version","errorCode":null,"errorMessage":"Failed to update dataset version","messagePattern":"Failed to update dataset version","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","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":142,"sourceCode":"\n        // Validate request\n        if (request.getDatasetVersionId() == null) {\n            throw new IllegalArgumentException(\"Version ID cannot be null\");\n        }\n\n\n        // Note: Version number updates are not supported in this implementation\n        // to maintain data integrity and prevent conflicts\n\n        // Update fields - only update available fields\n        int result = datasetVersionMapper.update(\n                request.getDatasetVersionId(),\n                request.getDescription(),\n                request.getStatus()\n        );\n\n        if (result <= 0) {\n            throw new RuntimeException(\"Failed to update dataset version\");\n        }\n\n        // Get updated version\n        DatasetVersionDO updatedVersionDO = datasetVersionMapper.selectById(request.getDatasetVersionId());\n        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\");","sourceCodeStart":124,"sourceCodeEnd":160,"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#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":"// before\nservice.update(requestWithId999); // id not present -> RuntimeException\n// after\nif (service.getById(id) != null) {\n    service.update(request);\n}","handlingStrategy":"validation","validationCode":"DatasetVersion existing = service.getById(request.getDatasetVersionId());\nif (existing == null) {\n    throw new IllegalStateException(\"Version \" + request.getDatasetVersionId() + \" does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return service.update(request);\n} catch (RuntimeException e) {\n    if (service.getById(request.getDatasetVersionId()) == null) {\n        throw new ResponseStatusException(HttpStatus.NOT_FOUND, \"dataset version not found\");\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["database","update-failed","record-not-found","dataset-version"],"backgroundTag":"database-write-failed","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"}