chore: added compatibility for no artifact json type attribute in metadata.json (#41156)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/16641904067>
> Commit: 83fbbcbcab702010f30a38cfe8b7f27c631e49f1
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=16641904067&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Thu, 31 Jul 2025 07:34:44 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved error handling during artifact type identification from Git
repositories, ensuring more specific error messages and defaulting to
the application artifact type in certain file system error cases.
* Enhanced clarity of error messages when required metadata is missing
or incomplete.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Manish Kumar 2025-08-07 14:37:30 +05:30 committed by GitHub
parent 5d38e47508
commit 9acfafdcaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -182,13 +182,26 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
return obtainArtifactTypeFromGitRepository(jsonTransformationDTO).zipWith(Mono.just(""));
}
protected Mono<ArtifactType> 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<ArtifactType> 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

View File

@ -867,7 +867,8 @@ public class CommonGitFileUtilsCE {
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 class CommonGitFileUtilsCE {
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());