diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java index 543785a763f..14d1239c1f5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java @@ -69,6 +69,7 @@ import org.openmetadata.service.OpenMetadataApplicationConfig; import org.openmetadata.service.apps.ApplicationHandler; import org.openmetadata.service.apps.scheduler.AppScheduler; import org.openmetadata.service.clients.pipeline.PipelineServiceClientFactory; +import org.openmetadata.service.exception.EntityNotFoundException; import org.openmetadata.service.jdbi3.AppRepository; import org.openmetadata.service.jdbi3.CollectionDAO; import org.openmetadata.service.jdbi3.IngestionPipelineRepository; @@ -130,9 +131,7 @@ public class AppResource extends EntityResource { null, createApp.getName(), new EntityUtil.Fields(repository.getMarketPlace().getAllowedFields())); - App app = - repository.getByName( - null, createApp.getName(), repository.getFields("bot,pipelines"), ALL, false); + App app = getAppForInit(createApp.getName()); if (app == null) { app = getApplication(definition, createApp, "admin") @@ -151,6 +150,14 @@ public class AppResource extends EntityResource { } } + private App getAppForInit(String appName) { + try { + return repository.getByName(null, appName, repository.getFields("bot,pipelines"), ALL, false); + } catch (EntityNotFoundException ex) { + return null; + } + } + public AppResource(Authorizer authorizer) { super(Entity.APPLICATION, authorizer); }