fix: Changed error message during import when fields are missing in the JSON (#27582)
## Description Instead of throwing 404, this PR informs the user which field is missing in the JSON. #### PR fixes following issue(s) Fixes #20493
This commit is contained in:
parent
ab91125748
commit
b399d747ab
|
|
@ -954,7 +954,7 @@ public class ImportExportApplicationServiceCEImpl implements ImportExportApplica
|
|||
private String validateApplicationJson(ApplicationJson importedDoc) {
|
||||
String errorField = "";
|
||||
if (CollectionUtils.isEmpty(importedDoc.getPageList())) {
|
||||
errorField = FieldName.PAGES;
|
||||
errorField = FieldName.PAGE_LIST;
|
||||
} else if (importedDoc.getExportedApplication() == null) {
|
||||
errorField = FieldName.APPLICATION;
|
||||
} else if (importedDoc.getActionList() == null) {
|
||||
|
|
@ -1835,7 +1835,8 @@ public class ImportExportApplicationServiceCEImpl implements ImportExportApplica
|
|||
String errorField = validateApplicationJson(importedDoc);
|
||||
if (!errorField.isEmpty()) {
|
||||
log.error("Error in importing application. Field {} is missing", errorField);
|
||||
return Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, errorField, INVALID_JSON_FILE));
|
||||
return Mono.error(new AppsmithException(
|
||||
AppsmithError.VALIDATION_FAILURE, "Field '" + errorField + "' is missing in the JSON."));
|
||||
}
|
||||
|
||||
Application importedApplication = importedDoc.getExportedApplication();
|
||||
|
|
|
|||
|
|
@ -842,7 +842,8 @@ public class ImportExportApplicationServiceTests {
|
|||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
&& throwable
|
||||
.getMessage()
|
||||
.equals(AppsmithError.NO_RESOURCE_FOUND.getMessage(FieldName.PAGES, INVALID_JSON_FILE)))
|
||||
.equals(AppsmithError.VALIDATION_FAILURE.getMessage(
|
||||
"Field '" + FieldName.PAGE_LIST + "' is missing in the JSON.")))
|
||||
.verify();
|
||||
}
|
||||
|
||||
|
|
@ -858,8 +859,8 @@ public class ImportExportApplicationServiceTests {
|
|||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
&& throwable
|
||||
.getMessage()
|
||||
.equals(AppsmithError.NO_RESOURCE_FOUND.getMessage(
|
||||
FieldName.APPLICATION, INVALID_JSON_FILE)))
|
||||
.equals(AppsmithError.VALIDATION_FAILURE.getMessage(
|
||||
"Field '" + FieldName.APPLICATION + "' is missing in the JSON.")))
|
||||
.verify();
|
||||
}
|
||||
|
||||
|
|
@ -4198,7 +4199,8 @@ public class ImportExportApplicationServiceTests {
|
|||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
&& throwable
|
||||
.getMessage()
|
||||
.equals(AppsmithError.NO_RESOURCE_FOUND.getMessage(FieldName.PAGES, INVALID_JSON_FILE)))
|
||||
.equals(AppsmithError.VALIDATION_FAILURE.getMessage(
|
||||
"Field '" + FieldName.PAGE_LIST + "' is missing in the JSON.")))
|
||||
.verify();
|
||||
|
||||
// Verify that the app card is not created
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user