diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateService.java index 47d9e64804..f4604beea4 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateService.java @@ -209,7 +209,8 @@ public class DefaultDevicePackageUpdateService extends AbstractTbEntityService i throw new IllegalArgumentException("The update has no steps"); } Set ownedIds = ownedIds(devicePackage.descriptor()); - Set stateKeys = new HashSet<>(); + // A form's values are saved under its key too, so an entity step may not share it + Set stateKeys = request.getInstallState() != null ? new HashSet<>(request.getInstallState().keySet()) : new HashSet<>(); for (DeviceUpdateRequest.Step step : request.getSteps()) { if (step.getName() == null || step.getAction() == null || !isKnownType(step.getType())) { throw new IllegalArgumentException("Invalid update step: " + step.getName()); diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java index 2ebf946bae..38595a0c71 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java @@ -497,6 +497,20 @@ class DefaultDevicePackageUpdateServiceTest { verify(transactionTemplate, never()).execute(any()); } + @Test + void stepWithTheKeyOfAForm_isRejected() { + DeviceUpdateRequest.Step step = keep("Dashboard", "DASHBOARD", dashboardId); + step.setId("Settings"); + DeviceUpdateRequest request = request(step); + request.setInstallState(Map.of("Settings", JacksonUtil.newObjectNode().set("formValues", JacksonUtil.newObjectNode().put("interval", 10)))); + + DeviceUpdateResult result = service.apply(user, installedItem.getId(), request); + + assertThat(result.isSuccess()).isFalse(); + assertThat(result.getErrorMessage()).isEqualTo("Duplicate update step: Settings"); + verify(transactionTemplate, never()).execute(any()); + } + @Test void stepsOfOneNameAndAnotherType_eachKeepTheirOwnState() { // Installed when the state was keyed by name: the integration's state replaced the converter's diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index 22e141c3ff..cf187de9dd 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -2609,7 +2609,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent