diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java index 3c9bba2d35b1..afc9a743163c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java @@ -182,13 +182,26 @@ public Mono> obtainArtifactTypeAndIdentifierFromGit return obtainArtifactTypeFromGitRepository(jsonTransformationDTO).zipWith(Mono.just("")); } + protected Mono handleErrorWhileArtifactTypeIdentification(Throwable exception) { + if (exception instanceof AppsmithException appsmithException + && AppsmithError.GIT_FILE_SYSTEM_ERROR.getAppErrorCode().equals(appsmithException.getAppErrorCode())) { + return Mono.just(ArtifactType.APPLICATION); + } + + return Mono.error(exception); + } + public Mono obtainArtifactTypeFromGitRepository(ArtifactJsonTransformationDTO jsonTransformationDTO) { String workspaceId = jsonTransformationDTO.getWorkspaceId(); String placeHolder = jsonTransformationDTO.getBaseArtifactId(); String repoName = jsonTransformationDTO.getRepoName(); Path temporaryStorage = Path.of(workspaceId, placeHolder, repoName); - return commonGitFileUtils.getArtifactJsonTypeOfRepository(temporaryStorage); + return commonGitFileUtils + .getArtifactJsonTypeOfRepository(temporaryStorage) + .onErrorResume(error -> { + return handleErrorWhileArtifactTypeIdentification(error); + }); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java index d0c04b9230b3..5c4c54603c81 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java @@ -867,7 +867,8 @@ public Mono getArtifactJsonTypeOfRepository(Path repoSuffix) { if (metadataJsonObject == null) { log.error( "Error in retrieving the metadata from the file system for repository {}", repoSuffix); - return Mono.error(new AppsmithException(AppsmithError.GIT_FILE_SYSTEM_ERROR)); + return Mono.error( + new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, CommonConstants.METADATA)); } JsonElement artifactJsonType = metadataJsonObject.get(ARTIFACT_JSON_TYPE); @@ -876,7 +877,8 @@ public Mono getArtifactJsonTypeOfRepository(Path repoSuffix) { log.error( "artifactJsonType attribute not found in the metadata file for repository {}", repoSuffix); - return Mono.error(new AppsmithException(AppsmithError.GIT_FILE_SYSTEM_ERROR)); + return Mono.error(new AppsmithException( + AppsmithError.GIT_FILE_SYSTEM_ERROR, "No artifactJsonType attribute found")); } return Mono.just(artifactJsonType.getAsString());