From 811713c338eb4e91619c549dabf92cbffdf16f7f Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 7 Sep 2026 15:12:03 +0300 Subject: [PATCH] compose the failed dependency sentence in the dialog, not in the service The service was pre-composing "Failed to install dependency '':", which can never be translated and made the backend depend on the dialog already printing the root item above the details. It now reports the failure itself, and the dialog prefixes a localized sentence when the entry that failed is not the root. --- .../service/iot_hub/DefaultIotHubService.java | 5 +---- .../service/solutions/DefaultSolutionService.java | 5 ----- .../service/iot_hub/DefaultIotHubServiceTest.java | 15 ++++++++++----- .../iot-hub/iot-hub-install-dialog.component.ts | 6 ++++++ .../src/assets/locale/locale.constant-en_US.json | 1 + 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java index 7f4bdfe089..db3f1d4549 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java @@ -1011,10 +1011,7 @@ public class DefaultIotHubService implements IotHubService { boolean rolledBack = rollbackInstalledItems(user, rollbackIds); result.setSuccess(false); result.setRolledBack(rolledBack); - // The dialog already says "Failed to install ''" above the details, so only a - // failing dependency is worth naming here - for the root entry that would just repeat itself. - result.setErrorMessage(entry.isRoot() ? e.getMessage() - : "Failed to install dependency '" + entry.getName() + "': " + e.getMessage()); + result.setErrorMessage(e.getMessage()); result.setEntries(resultEntries); result.setMissingItemIds(missingItemIds); return result; diff --git a/application/src/main/java/org/thingsboard/server/service/solutions/DefaultSolutionService.java b/application/src/main/java/org/thingsboard/server/service/solutions/DefaultSolutionService.java index b2c48f22b7..4c09f16e4c 100644 --- a/application/src/main/java/org/thingsboard/server/service/solutions/DefaultSolutionService.java +++ b/application/src/main/java/org/thingsboard/server/service/solutions/DefaultSolutionService.java @@ -299,11 +299,6 @@ public class DefaultSolutionService implements SolutionService { } } - /** - * Reports every entity of the template that would clash with an entity the tenant already has, naming each - * conflict, before anything is created. Returns {@code null} when the template can be installed as is. - * Package-private so the conflict detection can be unit-tested in isolation. - */ SolutionInstallResponse validateSolution(TenantId tenantId, Path tempDir) { //TODO: check other entities. diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java index bfe0db5750..c48e5896a1 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java @@ -345,7 +345,7 @@ class DefaultIotHubServiceTest { } @Test - void installPlan_rootFails_errorMessageIsNotPrefixedWithTheItemName() throws Exception { + void installPlan_errorMessageIsTheFailureItselfWithoutAnyPrefix() throws Exception { mockTenant(); HttpServletRequest request = mock(HttpServletRequest.class); String rootVersionId = UUID.randomUUID().toString(); @@ -356,12 +356,12 @@ class DefaultIotHubServiceTest { InstallPlanResult result = service.installPlan(user, new InstallPlan(rootVersionId, List.of(root)), null, request); - // the install dialog already shows "Failed to install ''" right above these details + // the sentence around the failure belongs to the dialog, which localizes it assertThat(result.getErrorMessage()).isEqualTo("install failed"); } @Test - void installPlan_dependencyFails_errorMessageNamesTheDependency() throws Exception { + void installPlan_dependencyFails_failureIsReportedOnTheEntryAndAsTheResultMessage() throws Exception { mockTenant(); HttpServletRequest request = mock(HttpServletRequest.class); String depVersionId = UUID.randomUUID().toString(); @@ -374,8 +374,13 @@ class DefaultIotHubServiceTest { InstallPlanResult result = service.installPlan(user, new InstallPlan(rootVersionId, List.of(dep, root)), null, request); - // a failing dependency is not the item the dialog names, so it has to be named here - assertThat(result.getErrorMessage()).isEqualTo("Failed to install dependency 'Dep': install failed"); + // the dialog names the failing dependency itself, from the entry it finds in the result + assertThat(result.getErrorMessage()).isEqualTo("install failed"); + assertThat(result.getEntries()).anySatisfy(entry -> { + assertThat(entry.getName()).isEqualTo("Dep"); + assertThat(entry.isRoot()).isFalse(); + assertThat(entry.getErrorMessage()).isEqualTo("install failed"); + }); verify(service, never()).doInstallVersion(eq(user), eq(rootVersionId), any(), any()); } diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts index 7de5717b66..78a36c074c 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts @@ -345,6 +345,12 @@ export class TbIotHubInstallDialogComponent extends DialogComponent !entry.root && entry.errorMessage); + if (failedDependency) { + message = this.translate.instant('iot-hub.install-dependency-error', { name: failedDependency.name }) + ' ' + message; + } // A failed cascade rolls back the items installed so far. When something was actually being // installed and the rollback came back partial (rolledBack === false), some entities are left // behind — tell the admin so they know manual cleanup may be needed. The willInstall guard diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 052d7ca046..19d2ac7484 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -4337,6 +4337,7 @@ "goto-main-dashboard": "Go to main dashboard", "install-error-title": "Installation Failed", "install-error-message": "Failed to install '{{name}}'.", + "install-dependency-error": "Failed to install the dependency '{{name}}':", "install-plan-title": "Install '{{name}}' and its dependencies", "install-plan-will-install": "{{count}} item(s) will be installed.", "install-plan-will-update": "{{count}} item(s) already installed and will be skipped.",