diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java index f851541c037..4e923d6aa0b 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java @@ -332,7 +332,7 @@ public abstract class EntityRepository { return JsonUtils.readValue(json, entityClass); } // If requested the latest version, return it from current version of the entity - T entity = setFields(dao.findEntityById(UUID.fromString(id)), putFields); + T entity = setFields(dao.findEntityById(UUID.fromString(id), Include.ALL), putFields); EntityInterface entityInterface = getEntityInterface(entity); if (entityInterface.getVersion().equals(requestedVersion)) { return entity; @@ -343,7 +343,7 @@ public abstract class EntityRepository { @Transaction public EntityHistory listVersions(String id) throws IOException, ParseException { - T latest = setFields(dao.findEntityById(UUID.fromString(id)), putFields); + T latest = setFields(dao.findEntityById(UUID.fromString(id), Include.ALL), putFields); String extensionPrefix = EntityUtil.getVersionExtensionPrefix(entityType); List oldVersions = daoCollection.entityExtensionDAO().getEntityVersions(id, extensionPrefix); oldVersions.sort(EntityUtil.compareVersion.reversed()); diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/EntityResourceTest.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/EntityResourceTest.java index d593c4faf89..983c4ffb395 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/EntityResourceTest.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/EntityResourceTest.java @@ -537,6 +537,19 @@ public abstract class EntityResourceTest extends CatalogApplicationTest { validateGetWithDifferentFields(entity, true); } + @Test + void get_deletedVersion(TestInfo test) throws IOException, URISyntaxException { + Object create = createRequest(getEntityName(test), "description", "displayName", USER_OWNER1); + T entity = createEntity(create, adminAuthHeaders()); + EntityInterface entityInterface = getEntityInterface(entity); + getEntity(entityInterface.getId(), null, allFields, adminAuthHeaders()); + deleteAndCheckEntity(entity, adminAuthHeaders()); + EntityHistory history = getVersionList(entityInterface.getId(), adminAuthHeaders()); + T latestVersion = JsonUtils.readValue((String) history.getVersions().get(0), entityClass); + entityInterface = getEntityInterface(latestVersion); + getVersion(entityInterface.getId(), entityInterface.getVersion(), adminAuthHeaders()); + } + @Test void get_entityIncludeDeleted_200(TestInfo test) throws IOException, URISyntaxException { Object create = createRequest(getEntityName(test), "description", "displayName", USER_OWNER1);