From 43851cd3f0236ebf9603ee6f2b297b59c471e98f Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Fri, 24 Jul 2026 17:08:27 +0300 Subject: [PATCH 01/39] Fix Nashorn Global PropertyMap leak on JS script release --- .../script/NashornJsInvokeServiceTest.java | 85 +++++++++++++++++++ .../script/api/js/NashornJsInvokeService.java | 16 +++- 2 files changed, 97 insertions(+), 4 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java index 01a5f1b6fc..c76eac8c61 100644 --- a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java @@ -17,13 +17,17 @@ package org.thingsboard.server.service.script; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import delight.nashornsandbox.NashornSandbox; +import delight.nashornsandbox.NashornSandboxes; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.util.ReflectionTestUtils; import org.thingsboard.common.util.TbStopWatch; +import org.thingsboard.script.api.RuleNodeScriptFactory; import org.thingsboard.script.api.ScriptType; import org.thingsboard.script.api.TbScriptException; import org.thingsboard.script.api.js.NashornJsInvokeService; @@ -31,6 +35,7 @@ import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.controller.AbstractControllerTest; import org.thingsboard.server.dao.service.DaoSqlTest; +import javax.script.ScriptEngine; import javax.script.ScriptException; import java.util.ArrayList; import java.util.List; @@ -222,6 +227,86 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest { }); } + @Test + void whenScriptIsReleased_thenGlobalPropertyIsRemoved() throws Exception { + UUID scriptId = evalScript("return msg;"); + String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("true"); + + invokeService.release(scriptId).get(); + + // the property must be deleted, not just set to undefined: an abandoned binding keeps + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("false"); + } + + @Test + void givenIifeWrappedEval_whenInvoking_thenResultIsUnchanged() throws Exception { + UUID scriptId = evalScript("return {doubled: msg.temperature * 2};"); + assertThat(invokeScript(scriptId, "{\"temperature\":21}")).contains("\"doubled\":42"); + } + + @Test + void givenIifeWrappedEval_thenImplicitGlobalStateIsStillSharedBetweenScripts() throws Exception { + UUID writer = evalScript("compatSharedState = 777; return msg;"); + UUID reader = evalScript("return {seen: (typeof compatSharedState === 'undefined') ? null : compatSharedState};"); + invokeScript(writer, "{}"); + assertThat(invokeScript(reader, "{}")).contains("\"seen\":777"); + } + + @Test + void givenIifeWrappedEval_thenCompilationErrorUnchanged() { + String badScript = "var a = 1;\nvar b = 2;\nreturn msg.temperature?.value;"; + + String legacyScript = RuleNodeScriptFactory.generateRuleNodeScript("invokeInternal_legacy", badScript, + "msg", "metadata", "msgType"); + NashornSandbox legacySandbox = NashornSandboxes.create(); + legacySandbox.allowNoBraces(false); + legacySandbox.allowLoadFunctions(true); + legacySandbox.setMaxPreparedStatements(30); + int legacyErrorLine = -1; + try { + legacySandbox.eval(legacyScript); + } catch (ScriptException e) { + legacyErrorLine = e.getLineNumber(); + } + assertThat(legacyErrorLine).isGreaterThan(0); + final int expectedLine = legacyErrorLine; + + assertThatThrownBy(() -> evalScript(badScript)) + .isInstanceOf(ExecutionException.class) + .cause() + .isInstanceOf(TbScriptException.class) + .asInstanceOf(type(TbScriptException.class)) + .satisfies(ex -> { + assertThat(ex.getErrorCode()).isEqualTo(TbScriptException.ErrorCode.COMPILATION); + assertThat(ex.getBody()).contains(badScript); + assertThat(ex.getCause()).isInstanceOf(ScriptException.class); + // The IIFE wrapper shifts sandbox-reported line numbers by a constant +2 + // (the beautifier splits the wrapper prefix onto its own lines). Reported + // lines never matched the user's source anyway (the sandbox instrumentation + // already offsets them), so only the small constant shift is tolerated here. + assertThat(((ScriptException) ex.getCause()).getLineNumber()).isBetween(expectedLine, expectedLine + 2); + }); + } + + @Test + void whenInvokingAfterRelease_thenFailsWithNoCompiledScriptFound() throws Exception { + UUID scriptId = evalScript("return msg;"); + invokeScript(scriptId, "{}"); + invokeService.release(scriptId).get(); + assertThatThrownBy(() -> invokeScript(scriptId, "{}")) + .isInstanceOf(ExecutionException.class) + .hasMessageContaining("No compiled script found"); + } + + private Object evalInEngine(String expression) throws Exception { + Object sandbox = ReflectionTestUtils.getField(invokeService, "sandbox"); + if (sandbox != null) { + return ((NashornSandbox) sandbox).eval(expression); + } + return ((ScriptEngine) ReflectionTestUtils.getField(invokeService, "engine")).eval(expression); + } + private void assertThatScriptIsBlocked(UUID scriptId) { assertThatThrownBy(() -> { invokeScript(scriptId, "{}"); diff --git a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java index 1ef2eeb6da..bb95c60481 100644 --- a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java +++ b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java @@ -140,14 +140,21 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { @Override protected ListenableFuture doEval(UUID scriptId, JsScriptInfo scriptInfo, String jsScript) { + // A top-level function declaration creates a non-configurable property on the Nashorn Global + // that can never be deleted, so every eval/release cycle would grow the Global's PropertyMap + // shape history forever. Declaring the function inside an IIFE and assigning it to a global + // property keeps the property configurable, allowing doRelease() to actually delete it. + // The prefix stays on the first line so that script line numbers in errors are unchanged. + String wrappedScript = "this['" + scriptInfo.getFunctionName() + "'] = (function() { " + jsScript + + "\nreturn " + scriptInfo.getFunctionName() + ";\n})();"; return jsExecutor.submit(() -> { try { evalLock.lock(); try { if (useJsSandbox) { - sandbox.eval(jsScript); + sandbox.eval(wrappedScript); } else { - engine.eval(jsScript); + engine.eval(wrappedScript); } } finally { evalLock.unlock(); @@ -182,10 +189,11 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { } protected void doRelease(UUID scriptId, JsScriptInfo scriptInfo) throws ScriptException { + String deleteScript = "delete this['" + scriptInfo.getFunctionName() + "'];"; if (useJsSandbox) { - sandbox.eval(scriptInfo.getFunctionName() + " = undefined;"); + sandbox.eval(deleteScript); } else { - engine.eval(scriptInfo.getFunctionName() + " = undefined;"); + engine.eval(deleteScript); } } From b67fc8dfb1ad1ca22dc076047f8ee37743b894f2 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Fri, 24 Jul 2026 17:08:39 +0300 Subject: [PATCH 02/39] Release EdgeGrpcClient channel on failed connect and guard send/disconnect race --- .../thingsboard/edge/rpc/EdgeGrpcClient.java | 146 +++++++++++------- 1 file changed, 92 insertions(+), 54 deletions(-) diff --git a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java index 7e58a2cb9f..f96fe8b38f 100644 --- a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java +++ b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java @@ -86,7 +86,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { private StreamObserver inputStream; - private static final ReentrantLock uplinkMsgLock = new ReentrantLock(); + private final ReentrantLock connectionLock = new ReentrantLock(); @Override public void connect(String edgeKey, @@ -127,19 +127,38 @@ public class EdgeGrpcClient implements EdgeRpcClient { .build()); } - channel = builder.build(); - EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); - log.info("[{}] Sending a connect request to the TB!", edgeKey); - this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) - .setConnectRequestMsg(ConnectRequestMsg.newBuilder() - .setEdgeRoutingKey(edgeKey) - .setEdgeSecret(edgeSecret) - .setEdgeVersion(getNewestEdgeVersion()) - .setMaxInboundMessageSize(maxInboundMessageSize) - .build()) - .build()); + connectionLock.lock(); + try { + channel = builder.build(); + EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); + log.info("[{}] Sending a connect request to the TB!", edgeKey); + this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, channel, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) + .setConnectRequestMsg(ConnectRequestMsg.newBuilder() + .setEdgeRoutingKey(edgeKey) + .setEdgeSecret(edgeSecret) + .setEdgeVersion(getNewestEdgeVersion()) + .setMaxInboundMessageSize(maxInboundMessageSize) + .build()) + .build()); + } catch (RuntimeException e) { + // Release the half-built channel, otherwise every failed reconnect attempt leaks + // its event loops and executors, and the next attempt may not recover at all. + log.error("[{}] Failed to establish the connection, shutting down the channel!", edgeKey, e); + if (channel != null) { + try { + channel.shutdownNow(); + } catch (Exception shutdownEx) { + log.error("[{}] Exception during shutdownNow of the failed channel", edgeKey, shutdownEx); + } + } + channel = null; + inputStream = null; + throw e; + } finally { + connectionLock.unlock(); + } } public static EdgeVersion getNewestEdgeVersion() { @@ -147,6 +166,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } private StreamObserver initOutputStream(String edgeKey, + ManagedChannel streamChannel, Consumer onUplinkResponse, Consumer onEdgeUpdate, Consumer onDownlink, @@ -166,7 +186,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } else { log.error("[{}] Failed to establish the connection! Code: {}. Error message: {}.", edgeKey, connectResponseMsg.getResponseCode(), connectResponseMsg.getErrorMsg()); try { - EdgeGrpcClient.this.disconnect(true); + EdgeGrpcClient.this.disconnect(true, streamChannel); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -188,7 +208,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { public void onError(Throwable t) { log.warn("[{}] Stream was terminated due to error:", edgeKey, t); try { - EdgeGrpcClient.this.disconnect(true); + EdgeGrpcClient.this.disconnect(true, streamChannel); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -204,77 +224,95 @@ public class EdgeGrpcClient implements EdgeRpcClient { @Override public void disconnect(boolean onError) throws InterruptedException { - if (!onError) { - try { - if (inputStream != null) { - inputStream.onCompleted(); + disconnect(onError, null); + } + + private void disconnect(boolean onError, ManagedChannel expectedChannel) throws InterruptedException { + ManagedChannel channelToShutdown; + connectionLock.lock(); + try { + // A terminated stream reports its error asynchronously and may lose the race with a + // reconnect: ignore such stale callbacks instead of tearing down the fresh channel. + if (expectedChannel != null && channel != expectedChannel) { + log.info("The channel was already replaced by a reconnect. Skipping disconnect of the stale channel."); + return; + } + if (!onError) { + try { + if (inputStream != null) { + inputStream.onCompleted(); + } + } catch (Exception e) { + log.error("Exception during onCompleted", e); } - } catch (Exception e) { - log.error("Exception during onCompleted", e); } + // Clear the references under the lock so that no send can start against a stream + // whose channel is shutting down - such a write leaks the compressed ByteBuf. + inputStream = null; + channelToShutdown = channel; + channel = null; + } finally { + connectionLock.unlock(); } - if (channel != null) { - channel.shutdown(); + if (channelToShutdown != null) { + channelToShutdown.shutdown(); int attempt = 0; do { try { - channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS); + channelToShutdown.awaitTermination(timeoutSecs, TimeUnit.SECONDS); } catch (Exception e) { log.error("Channel await termination was interrupted", e); } if (attempt > 5) { log.warn("We had reached maximum of termination attempts. Force closing channel"); try { - channel.shutdownNow(); + channelToShutdown.shutdownNow(); } catch (Exception e) { log.error("Exception during shutdownNow", e); } break; } attempt++; - } while (!channel.isTerminated()); + } while (!channelToShutdown.isTerminated()); } } @Override public void sendUplinkMsg(UplinkMsg msg) { - uplinkMsgLock.lock(); - try { - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setUplinkMsg(msg) - .build()); - } finally { - uplinkMsgLock.unlock(); - } + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setUplinkMsg(msg) + .build()); } @Override public void sendSyncRequestMsg(boolean fullSyncRequired) { - uplinkMsgLock.lock(); - try { - SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() - .setFullSync(fullSyncRequired) - .build(); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) - .setSyncRequestMsg(syncRequestMsg) - .build()); - } finally { - uplinkMsgLock.unlock(); - } + SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() + .setFullSync(fullSyncRequired) + .build(); + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) + .setSyncRequestMsg(syncRequestMsg) + .build()); } @Override public void sendDownlinkResponseMsg(DownlinkResponseMsg downlinkResponseMsg) { - uplinkMsgLock.lock(); + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setDownlinkResponseMsg(downlinkResponseMsg) + .build()); + } + + private void sendRequestMsg(RequestMsg requestMsg) { + connectionLock.lock(); try { - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setDownlinkResponseMsg(downlinkResponseMsg) - .build()); + if (inputStream == null) { + throw new IllegalStateException("Edge is not connected to the cloud. The message is discarded!"); + } + inputStream.onNext(requestMsg); } finally { - uplinkMsgLock.unlock(); + connectionLock.unlock(); } } From 1a15b5c94f729e0a7b09b13ca2e4a70b5c73e061 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 7 Sep 2026 15:11:49 +0300 Subject: [PATCH 03/39] report every conflicting entity before installing a solution template Only rule chains, profiles and dashboards were checked upfront, so a template with a clashing customer, asset, device or edge died mid install on a DB constraint and had to be rolled back. All of them are validated now, and every conflict is named and reported at once instead of repeating the same sentence per entity type. Rule chains are looked up by exact name and dashboards by exact title, since the paged text search matches with 'contains' and could report a different entity as the conflict. The install dialog also stopped repeating "Failed to install " inside the error details, since it is already shown right above them. --- .../service/iot_hub/DefaultIotHubService.java | 5 +- .../solutions/DefaultSolutionService.java | 147 +++++++++++------- .../iot_hub/DefaultIotHubServiceTest.java | 35 +++++ .../solutions/DefaultSolutionServiceTest.java | 133 ++++++++++++++++ 4 files changed, 262 insertions(+), 58 deletions(-) create mode 100644 application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java 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 f7cc08391a..cd90af6f26 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 @@ -952,7 +952,10 @@ public class DefaultIotHubService implements IotHubService { boolean rolledBack = rollbackInstalledItems(user, rollbackIds); result.setSuccess(false); result.setRolledBack(rolledBack); - result.setErrorMessage("Failed to install '" + entry.getName() + "': " + e.getMessage()); + // 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.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 34e56275e2..d84e681be6 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 @@ -32,7 +32,6 @@ import org.thingsboard.server.common.adaptor.JsonConverter; import org.thingsboard.server.common.data.AttributeScope; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.Customer; -import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.DeviceProfile; import org.thingsboard.server.common.data.HasName; import org.thingsboard.server.common.data.alarm.AlarmInfo; @@ -42,7 +41,6 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.iot_hub.SolutionTemplateInstalledItemDescriptor; import org.thingsboard.server.common.data.kv.BaseDeleteTsKvQuery; import org.thingsboard.server.common.data.kv.DeleteTsKvQuery; -import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.page.TimePageLink; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.StringUtils; @@ -151,12 +149,15 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ExecutorService; @@ -177,6 +178,11 @@ import java.util.zip.ZipInputStream; @Slf4j public class DefaultSolutionService implements SolutionService { + private static final String BLANK_LINE = System.lineSeparator() + System.lineSeparator(); + private static final String CONFLICTS_INTRO = + "Some entities of the solution template already exist. Rename or delete them and install the template again:"; + private static final String RANDOM_NAME_PLACEHOLDER_PREFIX = "$random"; + @Value("${ui.solution_templates.docs_base_url:https://thingsboard.io/docs}") private String docsBaseUrl; @@ -291,71 +297,102 @@ public class DefaultSolutionService implements SolutionService { } } - private SolutionInstallResponse validateSolution(TenantId tenantId, Path tempDir) { - Map> alreadyExistingEntities = new HashMap<>(); - + SolutionInstallResponse validateSolution(TenantId tenantId, Path tempDir) { //TODO: check other entities. List ruleChains = loadListOfEntitiesIfFileExists(tempDir, "rule_chains.json", new TypeReference<>() { }); - if (!ruleChains.isEmpty()) { - for (ReferenceableEntityDefinition ruleChain : ruleChains) { - List savedRuleChains = ruleChainService.findTenantRuleChainsByType(tenantId, RuleChainType.CORE, new PageLink(1, 0, ruleChain.getName())).getData(); - if (savedRuleChains != null && !savedRuleChains.isEmpty()) { - alreadyExistingEntities.computeIfAbsent(EntityType.RULE_CHAIN, key -> new ArrayList<>()).add(savedRuleChains.get(0)); - } - } - } - List deviceProfiles = loadListOfEntitiesIfFileExists(tempDir, "device_profiles.json", new TypeReference<>() { }); deviceProfiles.addAll(loadListOfEntitiesFromDirectory(tempDir, "device_profiles", DeviceProfileDefinition.class)); - // Validate that entities with such name does not exist entities - if (!deviceProfiles.isEmpty()) { - for (DeviceProfile deviceProfile : deviceProfiles) { - DeviceProfile savedProfile = deviceProfileService.findDeviceProfileByName(tenantId, deviceProfile.getName()); - if (savedProfile != null) { - alreadyExistingEntities.computeIfAbsent(EntityType.DEVICE_PROFILE, key -> new ArrayList<>()).add(savedProfile); - } - } - } - List assetProfiles = loadListOfEntitiesIfFileExists(tempDir, "asset_profiles.json", new TypeReference<>() { }); assetProfiles.addAll(loadListOfEntitiesFromDirectory(tempDir, "asset_profiles", AssetProfileDefinition.class)); - // Validate that entities with such name does not exist entities - if (!assetProfiles.isEmpty()) { - for (AssetProfile assetProfile : assetProfiles) { - AssetProfile savedProfile = assetProfileService.findAssetProfileByName(tenantId, assetProfile.getName()); - if (savedProfile != null) { - alreadyExistingEntities.computeIfAbsent(EntityType.ASSET_PROFILE, key -> new ArrayList<>()).add(savedProfile); - } - } - } - + List customers = loadListOfEntitiesIfFileExists(tempDir, "customers.json", new TypeReference<>() { + }); List dashboards = loadListOfEntitiesIfFileExists(tempDir, "dashboards.json", new TypeReference<>() { }); - if (!dashboards.isEmpty()) { - for (DashboardDefinition dashboard : dashboards) { - List savedDashboards = dashboardService.findDashboardsByTenantId(tenantId, new PageLink(1, 0, dashboard.getName())).getData(); - if (savedDashboards != null && !savedDashboards.isEmpty()) { - alreadyExistingEntities.computeIfAbsent(EntityType.DASHBOARD, key -> new ArrayList<>()).add(savedDashboards.get(0)); - } + List assets = loadListOfEntitiesIfFileExists(tempDir, "assets.json", new TypeReference<>() { + }); + List devices = loadListOfEntitiesIfFileExists(tempDir, "devices.json", new TypeReference<>() { + }); + List edges = loadListOfEntitiesIfFileExists(tempDir, "edges.json", new TypeReference<>() { + }); + + // Insertion ordered, so that the reported sections keep the order the entities are provisioned in. + Map> conflicts = new LinkedHashMap<>(); + collectConflicts(conflicts, EntityType.RULE_CHAIN, ruleChains, ReferenceableEntityDefinition::getName, + name -> firstOrNull(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.CORE, name))); + collectConflicts(conflicts, EntityType.DEVICE_PROFILE, deviceProfiles, DeviceProfile::getName, + name -> deviceProfileService.findDeviceProfileByName(tenantId, name)); + collectConflicts(conflicts, EntityType.ASSET_PROFILE, assetProfiles, AssetProfile::getName, + name -> assetProfileService.findAssetProfileByName(tenantId, name)); + collectConflicts(conflicts, EntityType.CUSTOMER, customers, CustomerDefinition::getName, + title -> isRandomizedAtInstall(title) ? null : customerService.findCustomerByTenantIdAndTitle(tenantId, title).orElse(null)); + collectConflicts(conflicts, EntityType.DASHBOARD, dashboards, DashboardDefinition::getName, + title -> dashboardService.findFirstDashboardInfoByTenantIdAndName(tenantId, title)); + collectConflicts(conflicts, EntityType.ASSET, assets, AssetDefinition::getName, + name -> assetService.findAssetByTenantIdAndName(tenantId, name)); + collectConflicts(conflicts, EntityType.DEVICE, devices, DeviceDefinition::getName, + name -> deviceService.findDeviceByTenantIdAndName(tenantId, name)); + collectConflicts(conflicts, EntityType.EDGE, edges, EdgeDefinition::getName, + name -> edgeService.findEdgeByTenantIdAndName(tenantId, name)); + + if (conflicts.isEmpty()) { + return null; + } + StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); + conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, + entities.stream().map(HasName::getName).map(DefaultSolutionService::quoted).toList())); + + SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); + solutionInstallResponse.setSuccess(false); + solutionInstallResponse.setDetails(details.toString()); + return solutionInstallResponse; + } + + private void collectConflicts(Map> conflicts, EntityType entityType, List definitions, + Function nameExtractor, Function lookup) { + for (T definition : definitions) { + String name = nameExtractor.apply(definition); + if (StringUtils.isEmpty(name)) { + continue; + } + HasName existing = lookup.apply(name); + if (existing != null) { + conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing); } } - if (!alreadyExistingEntities.isEmpty()) { - SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); - StringBuilder detailsBuilder = new StringBuilder(); - detailsBuilder.append("## Validation failed").append(System.lineSeparator()).append(System.lineSeparator()); - alreadyExistingEntities.forEach((type, list) -> detailsBuilder.append("The following **").append(getTypeLabel(type)).append("** entities already exist: ") - .append(list.stream().map(HasName::getName).map(name -> "'" + name + "'").collect(Collectors.joining(","))).append(";") - .append(System.lineSeparator()).append(System.lineSeparator())); - solutionInstallResponse.setSuccess(false); - solutionInstallResponse.setDetails(detailsBuilder.toString()); - return solutionInstallResponse; - } else { - return null; + } + + /** + * Only customer titles, user names and attribute values go through {@link #randomize}, so a {@code $random} + * placeholder in a customer title is replaced at install time and there is nothing to check upfront. Names of + * every other entity are used as written, placeholder included, so those are looked up as is - skipping them + * here would let the install die on a DB constraint again. + */ + private static boolean isRandomizedAtInstall(String name) { + return name.contains(RANDOM_NAME_PLACEHOLDER_PREFIX); + } + + /** + * One markdown list item per entity type, so that the names of the conflicting entities are what the user reads, + * instead of the same sentence repeated for every type. + */ + private void appendConflicts(StringBuilder details, EntityType entityType, List conflictDescriptions) { + if (conflictDescriptions.isEmpty()) { + return; } + details.append("- **").append(entityType.getNormalName()).append("**: ") + .append(conflictDescriptions.stream().distinct().collect(Collectors.joining(", "))).append(System.lineSeparator()); + } + + private static String quoted(String value) { + return "'" + value + "'"; + } + + private static T firstOrNull(Collection data) { + return data == null || data.isEmpty() ? null : data.iterator().next(); } private SolutionInstallResponse doInstallSolution(User user, TenantId tenantId, String solutionId, Path tempDir, HttpServletRequest request) { @@ -1450,10 +1487,6 @@ public class DefaultSolutionService implements SolutionService { return String.valueOf(now.toInstant().toEpochMilli()); } - private String getTypeLabel(EntityType type) { - return type.name().toLowerCase().replace('_', ' '); - } - private T loadEntityIfFileExists(Path tempDir, String fileName, Class clazz) { Path filePath = tempDir.resolve("entities").resolve(fileName); if (Files.exists(filePath)) { @@ -1467,7 +1500,7 @@ public class DefaultSolutionService implements SolutionService { Path filePath = tempDir.resolve("entities").resolve(fileName); if (Files.exists(filePath)) { try { - return JacksonUtil.readValue(filePath.toFile(), typeReference); + return Objects.requireNonNullElseGet(JacksonUtil.readValue(filePath.toFile(), typeReference), ArrayList::new); } catch (Exception e) { throw new IllegalArgumentException("Invalid json file " + fileName + " data structure", e); } 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 c252b58103..bfe0db5750 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 @@ -344,6 +344,41 @@ class DefaultIotHubServiceTest { inOrder.verify(service).deleteInstalledItem(user, dep1Item.getId()); } + @Test + void installPlan_rootFails_errorMessageIsNotPrefixedWithTheItemName() throws Exception { + mockTenant(); + HttpServletRequest request = mock(HttpServletRequest.class); + String rootVersionId = UUID.randomUUID().toString(); + InstallPlanEntry root = willInstall(rootVersionId, true); + + when(iotHubInstalledItemService.findInstalledItemIdsByTenantIdAndItemIdIn(eq(tenantId), any())).thenReturn(List.of()); + doThrow(new IllegalStateException("install failed")).when(service).doInstallVersion(eq(user), eq(rootVersionId), any(), any()); + + 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 + assertThat(result.getErrorMessage()).isEqualTo("install failed"); + } + + @Test + void installPlan_dependencyFails_errorMessageNamesTheDependency() throws Exception { + mockTenant(); + HttpServletRequest request = mock(HttpServletRequest.class); + String depVersionId = UUID.randomUUID().toString(); + String rootVersionId = UUID.randomUUID().toString(); + InstallPlanEntry dep = willInstall(depVersionId, false); + InstallPlanEntry root = willInstall(rootVersionId, true); + + when(iotHubInstalledItemService.findInstalledItemIdsByTenantIdAndItemIdIn(eq(tenantId), any())).thenReturn(List.of()); + doThrow(new IllegalStateException("install failed")).when(service).doInstallVersion(eq(user), eq(depVersionId), any(), any()); + + 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"); + verify(service, never()).doInstallVersion(eq(user), eq(rootVersionId), any(), any()); + } + @Test void installPlan_rollbackFailure_reportsNotFullyRolledBack() throws Exception { mockTenant(); diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java new file mode 100644 index 0000000000..a8c5697a42 --- /dev/null +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -0,0 +1,133 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.service.solutions; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.DashboardInfo; +import org.thingsboard.server.common.data.Device; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.dao.asset.AssetService; +import org.thingsboard.server.dao.customer.CustomerService; +import org.thingsboard.server.dao.dashboard.DashboardService; +import org.thingsboard.server.dao.device.DeviceService; +import org.thingsboard.server.service.solutions.data.solution.SolutionInstallResponse; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class DefaultSolutionServiceTest { + + private static final String CONFLICTS_INTRO = + "Some entities of the solution template already exist. Rename or delete them and install the template again:"; + + private final TenantId tenantId = TenantId.fromUUID(UUID.randomUUID()); + + @Mock + private CustomerService customerService; + @Mock + private DeviceService deviceService; + @Mock + private AssetService assetService; + @Mock + private DashboardService dashboardService; + + @InjectMocks + private DefaultSolutionService service; + + @TempDir + private Path tempDir; + + @Test + void testValidateSolutionNamesEveryConflictingEntity() throws IOException { + writeEntitiesFile("customers.json", "[{\"name\": \"Existing customer\"}, {\"name\": \"Customer $random\"}]"); + writeEntitiesFile("devices.json", "[{\"name\": \"Existing device\"}, {\"name\": \"New device\"}]"); + writeEntitiesFile("assets.json", "[{\"name\": \"New asset\"}]"); + + Customer customer = new Customer(); + customer.setTitle("Existing customer"); + Device device = new Device(); + device.setName("Existing device"); + + when(customerService.findCustomerByTenantIdAndTitle(tenantId, "Existing customer")).thenReturn(Optional.of(customer)); + when(assetService.findAssetByTenantIdAndName(tenantId, "New asset")).thenReturn(null); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "Existing device")).thenReturn(device); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result).isNotNull(); + assertThat(result.isSuccess()).isFalse(); + assertThat(result.getDetails().lines().toList()) + .containsSubsequence( + CONFLICTS_INTRO, + "- **Customer**: 'Existing customer'", + "- **Device**: 'Existing device'"); + // the randomized customer title and the entities that do not exist yet are not reported + assertThat(result.getDetails()) + .doesNotContain("Customer $random") + .doesNotContain("New device") + .doesNotContain("New asset"); + } + + @Test + void testValidateSolutionReportsConflictingDashboard() throws IOException { + writeEntitiesFile("dashboards.json", "[{\"name\": \"Overview\", \"file\": \"overview.json\"}]"); + + DashboardInfo dashboard = new DashboardInfo(); + dashboard.setTitle("Overview"); + when(dashboardService.findFirstDashboardInfoByTenantIdAndName(tenantId, "Overview")).thenReturn(dashboard); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result).isNotNull(); + assertThat(result.getDetails().lines().toList()) + .containsSubsequence(CONFLICTS_INTRO, "- **Dashboard**: 'Overview'"); + } + + @Test + void testValidateSolutionWithoutConflicts() throws IOException { + writeEntitiesFile("devices.json", "[{\"name\": \"New device\"}]"); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); + + assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + } + + @Test + void testValidateSolutionWithoutEntityFiles() { + assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + verifyNoInteractions(customerService, deviceService, assetService, dashboardService); + } + + private void writeEntitiesFile(String fileName, String content) throws IOException { + Path entitiesDir = Files.createDirectories(tempDir.resolve("entities")); + Files.writeString(entitiesDir.resolve(fileName), content); + } + +} From 56866d30c8522842a7d12b2c50e11108debe919c Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 7 Sep 2026 15:11:49 +0300 Subject: [PATCH 04/39] 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/iot_hub/DefaultIotHubServiceTest.java | 15 ++++++++++----- .../iot-hub/iot-hub-install-dialog.component.ts | 6 ++++++ .../src/assets/locale/locale.constant-en_US.json | 1 + 4 files changed, 18 insertions(+), 9 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 cd90af6f26..f7109c3bf2 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 @@ -952,10 +952,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/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 e4816d19ad..c55d708bcb 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 @@ -339,6 +339,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 98f59ec8a9..aefce04e88 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3850,6 +3850,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.", From 0d275e0d2cf75dca4f50506fe9107e80e3911829 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 7 Sep 2026 15:11:49 +0300 Subject: [PATCH 05/39] address review comments on the install validation - rule chains are looked up under the name from the rule chain file, the same source the install uses, instead of the name in rule_chains.json - the details end with a blank line, so the partial rollback warning the dialog appends does not land inside the last list item - an exception without a message falls back to its type, so the failing entry is still named - the dependency prefix is only added when the server sent an error message, since the fallback sentence names the root item --- .../service/iot_hub/DefaultIotHubService.java | 8 +++-- .../solutions/DefaultSolutionService.java | 22 ++++++++++++- .../iot_hub/DefaultIotHubServiceTest.java | 18 ++++++++++ .../solutions/DefaultSolutionServiceTest.java | 33 ++++++++++++++++++- .../iot-hub-install-dialog.component.ts | 10 +++--- 5 files changed, 83 insertions(+), 8 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 f7109c3bf2..1e41211cb2 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 @@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.thingsboard.common.util.JacksonUtil; +import org.thingsboard.server.common.data.StringUtils; import org.thingsboard.server.common.data.asset.AssetProfile; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.DeviceProfile; @@ -947,12 +948,15 @@ public class DefaultIotHubService implements IotHubService { } catch (Exception e) { log.error("[{}] Cascade install failed at entry {} ({}): {}", tenantId, entry.getName(), entry.getVersionId(), e.getMessage(), e); - resultEntry.setErrorMessage(e.getMessage()); + // an exception without a message would leave both the entry and the result blank, + // and the dialog would have nothing to name the failing entry by + String failure = StringUtils.isEmpty(e.getMessage()) ? e.getClass().getSimpleName() : e.getMessage(); + resultEntry.setErrorMessage(failure); resultEntries.add(resultEntry); boolean rolledBack = rollbackInstalledItems(user, rollbackIds); result.setSuccess(false); result.setRolledBack(rolledBack); - result.setErrorMessage(e.getMessage()); + result.setErrorMessage(failure); 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 d84e681be6..216960f4fe 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 @@ -321,7 +321,7 @@ public class DefaultSolutionService implements SolutionService { // Insertion ordered, so that the reported sections keep the order the entities are provisioned in. Map> conflicts = new LinkedHashMap<>(); - collectConflicts(conflicts, EntityType.RULE_CHAIN, ruleChains, ReferenceableEntityDefinition::getName, + collectConflicts(conflicts, EntityType.RULE_CHAIN, ruleChains, definition -> ruleChainName(tempDir, definition), name -> firstOrNull(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.CORE, name))); collectConflicts(conflicts, EntityType.DEVICE_PROFILE, deviceProfiles, DeviceProfile::getName, name -> deviceProfileService.findDeviceProfileByName(tenantId, name)); @@ -345,6 +345,9 @@ public class DefaultSolutionService implements SolutionService { conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, entities.stream().map(HasName::getName).map(DefaultSolutionService::quoted).toList())); + // the dialog appends its own sentences to these details, so the list has to end with a blank line + details.append(System.lineSeparator()); + SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); solutionInstallResponse.setSuccess(false); solutionInstallResponse.setDetails(details.toString()); @@ -391,6 +394,23 @@ public class DefaultSolutionService implements SolutionService { return "'" + value + "'"; } + /** + * The provisioned rule chain takes its name from the rule chain file, not from the name in rule_chains.json, + * so the conflict has to be looked up under the name the install will actually create. + */ + private String ruleChainName(Path tempDir, ReferenceableEntityDefinition definition) { + if (StringUtils.isEmpty(definition.getFile())) { + return null; + } + Path ruleChainPath = tempDir.resolve("rule_chains").resolve(definition.getFile()); + if (!Files.exists(ruleChainPath)) { + // provisionRuleChains logs and skips such a definition, so there is nothing to validate + return null; + } + JsonNode ruleChain = JacksonUtil.toJsonNode(ruleChainPath).get("ruleChain"); + return ruleChain != null && ruleChain.hasNonNull("name") ? ruleChain.get("name").asText() : null; + } + private static T firstOrNull(Collection data) { return data == null || data.isEmpty() ? null : data.iterator().next(); } 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 c48e5896a1..e34fd92d3c 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 @@ -384,6 +384,24 @@ class DefaultIotHubServiceTest { verify(service, never()).doInstallVersion(eq(user), eq(rootVersionId), any(), any()); } + @Test + void installPlan_failureWithoutMessage_reportsTheExceptionType() throws Exception { + mockTenant(); + HttpServletRequest request = mock(HttpServletRequest.class); + String rootVersionId = UUID.randomUUID().toString(); + InstallPlanEntry root = willInstall(rootVersionId, true); + + when(iotHubInstalledItemService.findInstalledItemIdsByTenantIdAndItemIdIn(eq(tenantId), any())).thenReturn(List.of()); + doThrow(new NullPointerException()).when(service).doInstallVersion(eq(user), eq(rootVersionId), any(), any()); + + InstallPlanResult result = service.installPlan(user, new InstallPlan(rootVersionId, List.of(root)), null, request); + + // the dialog looks the failing entry up by its error message, so it must never be blank + assertThat(result.getErrorMessage()).isEqualTo("NullPointerException"); + assertThat(result.getEntries()).allSatisfy(entry -> + assertThat(entry.getErrorMessage()).isEqualTo("NullPointerException")); + } + @Test void installPlan_rollbackFailure_reportsNotFullyRolledBack() throws Exception { mockTenant(); diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index a8c5697a42..04096c3cc3 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -25,15 +25,19 @@ import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.data.rule.RuleChain; +import org.thingsboard.server.common.data.rule.RuleChainType; import org.thingsboard.server.dao.asset.AssetService; import org.thingsboard.server.dao.customer.CustomerService; import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.dao.device.DeviceService; +import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.service.solutions.data.solution.SolutionInstallResponse; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; import java.util.Optional; import java.util.UUID; @@ -57,6 +61,8 @@ class DefaultSolutionServiceTest { private AssetService assetService; @Mock private DashboardService dashboardService; + @Mock + private RuleChainService ruleChainService; @InjectMocks private DefaultSolutionService service; @@ -89,6 +95,8 @@ class DefaultSolutionServiceTest { CONFLICTS_INTRO, "- **Customer**: 'Existing customer'", "- **Device**: 'Existing device'"); + // the dialog appends its own sentences, so the details have to end with a blank line + assertThat(result.getDetails()).endsWith(System.lineSeparator() + System.lineSeparator()); // the randomized customer title and the entities that do not exist yet are not reported assertThat(result.getDetails()) .doesNotContain("Customer $random") @@ -111,6 +119,23 @@ class DefaultSolutionServiceTest { .containsSubsequence(CONFLICTS_INTRO, "- **Dashboard**: 'Overview'"); } + @Test + void testValidateSolutionUsesTheRuleChainNameFromTheRuleChainFile() throws IOException { + writeEntitiesFile("rule_chains.json", "[{\"name\": \"Name in the definition\", \"file\": \"rc.json\"}]"); + writeFile("rule_chains/rc.json", "{\"ruleChain\": {\"name\": \"Name the install creates\"}}"); + + RuleChain ruleChain = new RuleChain(); + ruleChain.setName("Name the install creates"); + when(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.CORE, "Name the install creates")) + .thenReturn(List.of(ruleChain)); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result).isNotNull(); + assertThat(result.getDetails().lines().toList()) + .containsSubsequence(CONFLICTS_INTRO, "- **Rule chain**: 'Name the install creates'"); + } + @Test void testValidateSolutionWithoutConflicts() throws IOException { writeEntitiesFile("devices.json", "[{\"name\": \"New device\"}]"); @@ -122,7 +147,13 @@ class DefaultSolutionServiceTest { @Test void testValidateSolutionWithoutEntityFiles() { assertThat(service.validateSolution(tenantId, tempDir)).isNull(); - verifyNoInteractions(customerService, deviceService, assetService, dashboardService); + verifyNoInteractions(customerService, deviceService, assetService, dashboardService, ruleChainService); + } + + private void writeFile(String relativePath, String content) throws IOException { + Path file = tempDir.resolve(relativePath); + Files.createDirectories(file.getParent()); + Files.writeString(file, content); } private void writeEntitiesFile(String fileName, String content) throws IOException { 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 c55d708bcb..54a8409063 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 @@ -338,10 +338,12 @@ export class TbIotHubInstallDialogComponent extends DialogComponent !entry.root && entry.errorMessage); + const serverError = result.errorMessage; + let message = serverError || this.translate.instant('iot-hub.install-error', { name: this.item.name }); + // The title already names the item being installed, so only a failing dependency has to be named + // here - and only when the server reported the failure, since the fallback above names the root. + const failedDependency = serverError + ? (result.entries ?? []).find(entry => !entry.root && entry.errorMessage) : undefined; if (failedDependency) { message = this.translate.instant('iot-hub.install-dependency-error', { name: failedDependency.name }) + ' ' + message; } From 6fe4852f9b953e9d73ac009de56031550f4b650a Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 7 Sep 2026 15:56:03 +0300 Subject: [PATCH 06/39] address the second review pass on the install validation - the dialog no longer mistakes a MISSING plan entry for the failing one: such entries carry an error message of their own with no name, so the lookup now also requires the WILL_INSTALL status - the whole dependency sentence lives in the locale bundle as one key with a name and an error parameter, instead of a fragment glued to the server message, and the partial rollback warning is appended as its own paragraph by the dialog rather than relying on the details ending with a blank line - a rule chain is validated under the type from the rule chain file too, so an EDGE chain is no longer looked up among the CORE ones - names are deduplicated before the lookup rather than when formatting, so a template repeating a name queries once - the entity type and the name come from the definition itself for the five lists that carry both, which removes the pairing hazard - ExceptionUtil.getMessage replaces the hand-rolled fallback, and the single-use firstOrNull helper is inlined - the dashboard check moved after the device one to match the provision order the comment claims, and the unreachable empty-list guard is gone - tests cover both profile types, edges, the rule chain type and its two unresolvable-name branches, the deduplicated lookup and a json file holding null --- .../service/iot_hub/DefaultIotHubService.java | 10 +- .../solutions/DefaultSolutionService.java | 130 ++++++++++-------- .../solutions/DefaultSolutionServiceTest.java | 88 +++++++++++- .../iot-hub-install-dialog.component.ts | 14 +- .../assets/locale/locale.constant-en_US.json | 2 +- 5 files changed, 173 insertions(+), 71 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 1e41211cb2..f7f5fae4a5 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 @@ -20,8 +20,8 @@ import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.thingsboard.common.util.ExceptionUtil; import org.thingsboard.common.util.JacksonUtil; -import org.thingsboard.server.common.data.StringUtils; import org.thingsboard.server.common.data.asset.AssetProfile; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.DeviceProfile; @@ -948,15 +948,13 @@ public class DefaultIotHubService implements IotHubService { } catch (Exception e) { log.error("[{}] Cascade install failed at entry {} ({}): {}", tenantId, entry.getName(), entry.getVersionId(), e.getMessage(), e); - // an exception without a message would leave both the entry and the result blank, - // and the dialog would have nothing to name the failing entry by - String failure = StringUtils.isEmpty(e.getMessage()) ? e.getClass().getSimpleName() : e.getMessage(); - resultEntry.setErrorMessage(failure); + String failureMessage = ExceptionUtil.getMessage(e); + resultEntry.setErrorMessage(failureMessage); resultEntries.add(resultEntry); boolean rolledBack = rollbackInstalledItems(user, rollbackIds); result.setSuccess(false); result.setRolledBack(rolledBack); - result.setErrorMessage(failure); + result.setErrorMessage(failureMessage); 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 216960f4fe..cdeb9c06af 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 @@ -124,6 +124,7 @@ import org.thingsboard.server.service.solutions.data.definition.UserDefinition; import org.thingsboard.server.service.solutions.data.definition.DashboardDefinition; import org.thingsboard.server.service.solutions.data.definition.DeviceProfileDefinition; import org.thingsboard.server.service.solutions.data.definition.EdgeDefinition; +import org.thingsboard.server.service.solutions.data.definition.EntityDefinition; import org.thingsboard.server.service.solutions.data.definition.RelationDefinition; import org.thingsboard.server.service.solutions.data.definition.ReferenceableEntityDefinition; import org.thingsboard.server.service.solutions.data.definition.TenantDefinition; @@ -181,7 +182,7 @@ public class DefaultSolutionService implements SolutionService { private static final String BLANK_LINE = System.lineSeparator() + System.lineSeparator(); private static final String CONFLICTS_INTRO = "Some entities of the solution template already exist. Rename or delete them and install the template again:"; - private static final String RANDOM_NAME_PLACEHOLDER_PREFIX = "$random"; + private static final String RANDOM_PLACEHOLDER = "$random"; @Value("${ui.solution_templates.docs_base_url:https://thingsboard.io/docs}") private String docsBaseUrl; @@ -321,32 +322,23 @@ public class DefaultSolutionService implements SolutionService { // Insertion ordered, so that the reported sections keep the order the entities are provisioned in. Map> conflicts = new LinkedHashMap<>(); - collectConflicts(conflicts, EntityType.RULE_CHAIN, ruleChains, definition -> ruleChainName(tempDir, definition), - name -> firstOrNull(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.CORE, name))); + collectRuleChainConflicts(conflicts, tenantId, tempDir, ruleChains); collectConflicts(conflicts, EntityType.DEVICE_PROFILE, deviceProfiles, DeviceProfile::getName, name -> deviceProfileService.findDeviceProfileByName(tenantId, name)); collectConflicts(conflicts, EntityType.ASSET_PROFILE, assetProfiles, AssetProfile::getName, name -> assetProfileService.findAssetProfileByName(tenantId, name)); - collectConflicts(conflicts, EntityType.CUSTOMER, customers, CustomerDefinition::getName, - title -> isRandomizedAtInstall(title) ? null : customerService.findCustomerByTenantIdAndTitle(tenantId, title).orElse(null)); - collectConflicts(conflicts, EntityType.DASHBOARD, dashboards, DashboardDefinition::getName, - title -> dashboardService.findFirstDashboardInfoByTenantIdAndName(tenantId, title)); - collectConflicts(conflicts, EntityType.ASSET, assets, AssetDefinition::getName, - name -> assetService.findAssetByTenantIdAndName(tenantId, name)); - collectConflicts(conflicts, EntityType.DEVICE, devices, DeviceDefinition::getName, - name -> deviceService.findDeviceByTenantIdAndName(tenantId, name)); - collectConflicts(conflicts, EntityType.EDGE, edges, EdgeDefinition::getName, - name -> edgeService.findEdgeByTenantIdAndName(tenantId, name)); + collectConflicts(conflicts, customers, + title -> isRandomizedCustomerTitle(title) ? null : customerService.findCustomerByTenantIdAndTitle(tenantId, title).orElse(null)); + collectConflicts(conflicts, assets, name -> assetService.findAssetByTenantIdAndName(tenantId, name)); + collectConflicts(conflicts, devices, name -> deviceService.findDeviceByTenantIdAndName(tenantId, name)); + collectConflicts(conflicts, dashboards, title -> dashboardService.findFirstDashboardInfoByTenantIdAndName(tenantId, title)); + collectConflicts(conflicts, edges, name -> edgeService.findEdgeByTenantIdAndName(tenantId, name)); if (conflicts.isEmpty()) { return null; } StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); - conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, - entities.stream().map(HasName::getName).map(DefaultSolutionService::quoted).toList())); - - // the dialog appends its own sentences to these details, so the list has to end with a blank line - details.append(System.lineSeparator()); + conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, entities)); SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); solutionInstallResponse.setSuccess(false); @@ -354,65 +346,91 @@ public class DefaultSolutionService implements SolutionService { return solutionInstallResponse; } + /** + * The entity type and the name both come from the definition, so a list can not end up checked against the + * wrong type by mistake. + */ + private void collectConflicts(Map> conflicts, List definitions, + Function lookup) { + Set checked = new HashSet<>(); + for (EntityDefinition definition : definitions) { + if (checked.add(definition.getName())) { + collectConflict(conflicts, definition.getEntityType(), definition.getName(), lookup); + } + } + } + private void collectConflicts(Map> conflicts, EntityType entityType, List definitions, Function nameExtractor, Function lookup) { + Set checked = new HashSet<>(); for (T definition : definitions) { String name = nameExtractor.apply(definition); - if (StringUtils.isEmpty(name)) { + if (checked.add(name)) { + collectConflict(conflicts, entityType, name, lookup); + } + } + } + + private void collectConflict(Map> conflicts, EntityType entityType, String name, + Function lookup) { + if (StringUtils.isEmpty(name)) { + return; + } + HasName existing = lookup.apply(name); + if (existing != null) { + conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing); + } + } + + /** + * A rule chain is created from the rule chain file, so both the name and the type of the chain the install will + * produce live there - the name in rule_chains.json is only a reference and the type defaults to CORE. + */ + private void collectRuleChainConflicts(Map> conflicts, TenantId tenantId, Path tempDir, + List definitions) { + Set checked = new HashSet<>(); + for (ReferenceableEntityDefinition definition : definitions) { + if (StringUtils.isEmpty(definition.getFile())) { + continue; + } + Path ruleChainPath = tempDir.resolve("rule_chains").resolve(definition.getFile()); + if (!Files.exists(ruleChainPath)) { + // provisionRuleChains logs and skips such a definition, so there is nothing to validate continue; } - HasName existing = lookup.apply(name); - if (existing != null) { - conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing); + JsonNode ruleChain = JacksonUtil.toJsonNode(ruleChainPath).get("ruleChain"); + if (ruleChain == null || !ruleChain.hasNonNull("name")) { + continue; + } + RuleChainType type = ruleChain.hasNonNull("type") + ? RuleChainType.valueOf(ruleChain.get("type").asText()) : RuleChainType.CORE; + String name = ruleChain.get("name").asText(); + if (!checked.add(type + name)) { + continue; } + collectConflict(conflicts, EntityType.RULE_CHAIN, name, + ignored -> ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, type, name) + .stream().findFirst().orElse(null)); } } /** * Only customer titles, user names and attribute values go through {@link #randomize}, so a {@code $random} * placeholder in a customer title is replaced at install time and there is nothing to check upfront. Names of - * every other entity are used as written, placeholder included, so those are looked up as is - skipping them - * here would let the install die on a DB constraint again. + * every other entity are used as written, placeholder included, and must be looked up as is. */ - private static boolean isRandomizedAtInstall(String name) { - return name.contains(RANDOM_NAME_PLACEHOLDER_PREFIX); + private static boolean isRandomizedCustomerTitle(String title) { + return title.contains(RANDOM_PLACEHOLDER); } /** * One markdown list item per entity type, so that the names of the conflicting entities are what the user reads, * instead of the same sentence repeated for every type. */ - private void appendConflicts(StringBuilder details, EntityType entityType, List conflictDescriptions) { - if (conflictDescriptions.isEmpty()) { - return; - } + private void appendConflicts(StringBuilder details, EntityType entityType, List entities) { details.append("- **").append(entityType.getNormalName()).append("**: ") - .append(conflictDescriptions.stream().distinct().collect(Collectors.joining(", "))).append(System.lineSeparator()); - } - - private static String quoted(String value) { - return "'" + value + "'"; - } - - /** - * The provisioned rule chain takes its name from the rule chain file, not from the name in rule_chains.json, - * so the conflict has to be looked up under the name the install will actually create. - */ - private String ruleChainName(Path tempDir, ReferenceableEntityDefinition definition) { - if (StringUtils.isEmpty(definition.getFile())) { - return null; - } - Path ruleChainPath = tempDir.resolve("rule_chains").resolve(definition.getFile()); - if (!Files.exists(ruleChainPath)) { - // provisionRuleChains logs and skips such a definition, so there is nothing to validate - return null; - } - JsonNode ruleChain = JacksonUtil.toJsonNode(ruleChainPath).get("ruleChain"); - return ruleChain != null && ruleChain.hasNonNull("name") ? ruleChain.get("name").asText() : null; - } - - private static T firstOrNull(Collection data) { - return data == null || data.isEmpty() ? null : data.iterator().next(); + .append(entities.stream().map(entity -> "'" + entity.getName() + "'").collect(Collectors.joining(", "))) + .append(System.lineSeparator()); } private SolutionInstallResponse doInstallSolution(User user, TenantId tenantId, String solutionId, Path tempDir, HttpServletRequest request) { diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index 04096c3cc3..d89012057b 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -24,13 +24,19 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.Device; +import org.thingsboard.server.common.data.DeviceProfile; +import org.thingsboard.server.common.data.asset.AssetProfile; +import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.rule.RuleChain; import org.thingsboard.server.common.data.rule.RuleChainType; +import org.thingsboard.server.dao.asset.AssetProfileService; import org.thingsboard.server.dao.asset.AssetService; import org.thingsboard.server.dao.customer.CustomerService; import org.thingsboard.server.dao.dashboard.DashboardService; +import org.thingsboard.server.dao.device.DeviceProfileService; import org.thingsboard.server.dao.device.DeviceService; +import org.thingsboard.server.dao.edge.EdgeService; import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.service.solutions.data.solution.SolutionInstallResponse; @@ -42,6 +48,8 @@ import java.util.Optional; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; @@ -63,6 +71,12 @@ class DefaultSolutionServiceTest { private DashboardService dashboardService; @Mock private RuleChainService ruleChainService; + @Mock + private DeviceProfileService deviceProfileService; + @Mock + private AssetProfileService assetProfileService; + @Mock + private EdgeService edgeService; @InjectMocks private DefaultSolutionService service; @@ -95,8 +109,6 @@ class DefaultSolutionServiceTest { CONFLICTS_INTRO, "- **Customer**: 'Existing customer'", "- **Device**: 'Existing device'"); - // the dialog appends its own sentences, so the details have to end with a blank line - assertThat(result.getDetails()).endsWith(System.lineSeparator() + System.lineSeparator()); // the randomized customer title and the entities that do not exist yet are not reported assertThat(result.getDetails()) .doesNotContain("Customer $random") @@ -136,6 +148,78 @@ class DefaultSolutionServiceTest { .containsSubsequence(CONFLICTS_INTRO, "- **Rule chain**: 'Name the install creates'"); } + @Test + void testValidateSolutionReportsConflictingProfilesAndEdge() throws IOException { + writeEntitiesFile("device_profiles.json", "[{\"name\": \"thermostat\"}]"); + writeEntitiesFile("asset_profiles.json", "[{\"name\": \"building\"}]"); + writeEntitiesFile("edges.json", "[{\"name\": \"Main edge\"}]"); + + DeviceProfile deviceProfile = new DeviceProfile(); + deviceProfile.setName("thermostat"); + AssetProfile assetProfile = new AssetProfile(); + assetProfile.setName("building"); + Edge edge = new Edge(); + edge.setName("Main edge"); + when(deviceProfileService.findDeviceProfileByName(tenantId, "thermostat")).thenReturn(deviceProfile); + when(assetProfileService.findAssetProfileByName(tenantId, "building")).thenReturn(assetProfile); + when(edgeService.findEdgeByTenantIdAndName(tenantId, "Main edge")).thenReturn(edge); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result).isNotNull(); + assertThat(result.getDetails().lines().toList()).containsSubsequence( + "- **Device profile**: 'thermostat'", + "- **Asset profile**: 'building'", + "- **Edge**: 'Main edge'"); + } + + @Test + void testValidateSolutionLooksTheSameNameUpOnce() throws IOException { + writeEntitiesFile("devices.json", "[{\"name\": \"Sensor\"}, {\"name\": \"Sensor\"}]"); + + Device device = new Device(); + device.setName("Sensor"); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor")).thenReturn(device); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result.getDetails().lines().toList()).contains("- **Device**: 'Sensor'"); + verify(deviceService, times(1)).findDeviceByTenantIdAndName(tenantId, "Sensor"); + } + + @Test + void testValidateSolutionSkipsRuleChainsWithoutAResolvableName() throws IOException { + writeEntitiesFile("rule_chains.json", "[{\"name\": \"No file\", \"file\": \"missing.json\"}," + + "{\"name\": \"No name inside\", \"file\": \"nameless.json\"}]"); + writeFile("rule_chains/nameless.json", "{\"ruleChain\": {}}"); + + assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + verifyNoInteractions(ruleChainService); + } + + @Test + void testValidateSolutionUsesTheRuleChainTypeFromTheRuleChainFile() throws IOException { + writeEntitiesFile("rule_chains.json", "[{\"name\": \"Edge chain\", \"file\": \"rc.json\"}]"); + writeFile("rule_chains/rc.json", "{\"ruleChain\": {\"name\": \"Edge chain\", \"type\": \"EDGE\"}}"); + + RuleChain ruleChain = new RuleChain(); + ruleChain.setName("Edge chain"); + when(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.EDGE, "Edge chain")) + .thenReturn(List.of(ruleChain)); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result.getDetails().lines().toList()).contains("- **Rule chain**: 'Edge chain'"); + } + + @Test + void testValidateSolutionTreatsAJsonNullFileAsEmpty() throws IOException { + writeEntitiesFile("devices.json", "null"); + + assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + verifyNoInteractions(deviceService); + } + @Test void testValidateSolutionWithoutConflicts() throws IOException { writeEntitiesFile("devices.json", "[{\"name\": \"New device\"}]"); 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 54a8409063..f777a4da31 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 @@ -340,19 +340,21 @@ export class TbIotHubInstallDialogComponent extends DialogComponent !entry.root && entry.errorMessage) : undefined; + // The title already names the item being installed, so only a failing dependency has to be named here, and + // only when the server reported the failure - the fallback above names the root. A missing entry carries an + // error message of its own, so the failing one is the entry the cascade actually tried to install. + const failedDependency = serverError ? (result.entries ?? []).find( + entry => !entry.root && entry.errorMessage && entry.status === InstallPlanEntryStatus.WILL_INSTALL) : undefined; if (failedDependency) { - message = this.translate.instant('iot-hub.install-dependency-error', { name: failedDependency.name }) + ' ' + message; + message = this.translate.instant('iot-hub.install-dependency-error', + { name: failedDependency.name, error: 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 // avoids the misleading warning on the "empty plan" failure, where nothing was installed. if (!result.rolledBack && this.planSummary.willInstall > 0) { - message += ' ' + this.translate.instant('iot-hub.install-rollback-partial'); + message += '\n\n' + this.translate.instant('iot-hub.install-rollback-partial'); } this.errorMessage = message; return; 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 aefce04e88..b5f51fd6d4 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3850,7 +3850,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-dependency-error": "Failed to install the dependency '{{name}}': {{error}}", "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.", From f97bc57694821c4ef8d8ca05222e9319cd44c9d7 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Tue, 8 Sep 2026 13:36:49 +0300 Subject: [PATCH 07/39] address the PE review notes on the install report - drop the java.util.Collection import that stayed behind when firstOrNull was inlined - cap each report section at ten names plus "and N more": a template can hold hundreds of devices, and the dialog renders these details without the height cap the plain-text branch has - leave the details empty when the server reported no message of its own, since the description above them already names the item that failed - cover the asset conflict, the capped report and the remaining mocks in the validation test --- .../solutions/DefaultSolutionService.java | 14 ++++++--- .../solutions/DefaultSolutionServiceTest.java | 31 +++++++++++++++++-- .../iot-hub-install-dialog.component.html | 14 +++++---- .../iot-hub-install-dialog.component.ts | 18 ++++++----- 4 files changed, 56 insertions(+), 21 deletions(-) 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 cdeb9c06af..352d4d4e17 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 @@ -150,7 +150,6 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -183,6 +182,7 @@ public class DefaultSolutionService implements SolutionService { private static final String CONFLICTS_INTRO = "Some entities of the solution template already exist. Rename or delete them and install the template again:"; private static final String RANDOM_PLACEHOLDER = "$random"; + private static final int MAX_REPORTED_CONFLICTS = 10; @Value("${ui.solution_templates.docs_base_url:https://thingsboard.io/docs}") private String docsBaseUrl; @@ -338,7 +338,8 @@ public class DefaultSolutionService implements SolutionService { return null; } StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); - conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, entities)); + conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, + entities.stream().map(entity -> "'" + entity.getName() + "'").toList())); SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); solutionInstallResponse.setSuccess(false); @@ -427,10 +428,13 @@ public class DefaultSolutionService implements SolutionService { * One markdown list item per entity type, so that the names of the conflicting entities are what the user reads, * instead of the same sentence repeated for every type. */ - private void appendConflicts(StringBuilder details, EntityType entityType, List entities) { + private void appendConflicts(StringBuilder details, EntityType entityType, List conflictDescriptions) { details.append("- **").append(entityType.getNormalName()).append("**: ") - .append(entities.stream().map(entity -> "'" + entity.getName() + "'").collect(Collectors.joining(", "))) - .append(System.lineSeparator()); + .append(conflictDescriptions.stream().limit(MAX_REPORTED_CONFLICTS).collect(Collectors.joining(", "))); + if (conflictDescriptions.size() > MAX_REPORTED_CONFLICTS) { + details.append(" and ").append(conflictDescriptions.size() - MAX_REPORTED_CONFLICTS).append(" more"); + } + details.append(System.lineSeparator()); } private SolutionInstallResponse doInstallSolution(User user, TenantId tenantId, String solutionId, Path tempDir, HttpServletRequest request) { diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index d89012057b..d28955e742 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -25,6 +25,7 @@ import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.DeviceProfile; +import org.thingsboard.server.common.data.asset.Asset; import org.thingsboard.server.common.data.asset.AssetProfile; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.id.TenantId; @@ -46,6 +47,8 @@ import java.nio.file.Path; import java.util.List; import java.util.Optional; import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.times; @@ -88,7 +91,7 @@ class DefaultSolutionServiceTest { void testValidateSolutionNamesEveryConflictingEntity() throws IOException { writeEntitiesFile("customers.json", "[{\"name\": \"Existing customer\"}, {\"name\": \"Customer $random\"}]"); writeEntitiesFile("devices.json", "[{\"name\": \"Existing device\"}, {\"name\": \"New device\"}]"); - writeEntitiesFile("assets.json", "[{\"name\": \"New asset\"}]"); + writeEntitiesFile("assets.json", "[{\"name\": \"Existing asset\"}, {\"name\": \"New asset\"}]"); Customer customer = new Customer(); customer.setTitle("Existing customer"); @@ -96,6 +99,9 @@ class DefaultSolutionServiceTest { device.setName("Existing device"); when(customerService.findCustomerByTenantIdAndTitle(tenantId, "Existing customer")).thenReturn(Optional.of(customer)); + Asset asset = new Asset(); + asset.setName("Existing asset"); + when(assetService.findAssetByTenantIdAndName(tenantId, "Existing asset")).thenReturn(asset); when(assetService.findAssetByTenantIdAndName(tenantId, "New asset")).thenReturn(null); when(deviceService.findDeviceByTenantIdAndName(tenantId, "Existing device")).thenReturn(device); when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); @@ -108,6 +114,7 @@ class DefaultSolutionServiceTest { .containsSubsequence( CONFLICTS_INTRO, "- **Customer**: 'Existing customer'", + "- **Asset**: 'Existing asset'", "- **Device**: 'Existing device'"); // the randomized customer title and the entities that do not exist yet are not reported assertThat(result.getDetails()) @@ -220,6 +227,25 @@ class DefaultSolutionServiceTest { verifyNoInteractions(deviceService); } + @Test + void testValidateSolutionCapsTheNamesItLists() throws IOException { + String definitions = IntStream.rangeClosed(1, 12) + .mapToObj(i -> "{\"name\": \"Sensor " + i + "\"}") + .collect(Collectors.joining(",")); + writeEntitiesFile("devices.json", "[" + definitions + "]"); + for (int i = 1; i <= 12; i++) { + Device device = new Device(); + device.setName("Sensor " + i); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor " + i)).thenReturn(device); + } + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + assertThat(result.getDetails().lines().toList()) + .contains("- **Device**: 'Sensor 1', 'Sensor 2', 'Sensor 3', 'Sensor 4', 'Sensor 5', 'Sensor 6', " + + "'Sensor 7', 'Sensor 8', 'Sensor 9', 'Sensor 10' and 2 more"); + } + @Test void testValidateSolutionWithoutConflicts() throws IOException { writeEntitiesFile("devices.json", "[{\"name\": \"New device\"}]"); @@ -231,7 +257,8 @@ class DefaultSolutionServiceTest { @Test void testValidateSolutionWithoutEntityFiles() { assertThat(service.validateSolution(tenantId, tempDir)).isNull(); - verifyNoInteractions(customerService, deviceService, assetService, dashboardService, ruleChainService); + verifyNoInteractions(customerService, deviceService, assetService, dashboardService, ruleChainService, + deviceProfileService, assetProfileService, edgeService); } private void writeFile(String relativePath, String content) throws IOException { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html index 25c5ca2089..d267ccf57e 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html @@ -141,12 +141,14 @@ @case ('error') {

{{ 'iot-hub.install-error-title' | translate }}

{{ 'iot-hub.install-error-message' | translate:{ name: item.name } }}

- @if (item.type === ItemType.SOLUTION_TEMPLATE) { - - } @else { -
- {{ errorMessage }} -
+ @if (errorMessage) { + @if (item.type === ItemType.SOLUTION_TEMPLATE) { + + } @else { +
+ {{ errorMessage }} +
+ } } } } 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 f777a4da31..5fe6879e5e 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 @@ -308,7 +308,7 @@ export class TbIotHubInstallDialogComponent extends DialogComponent { if (!result.success) { this.state = 'error'; - this.errorMessage = result.errorMessage || this.translate.instant('iot-hub.install-error', { name: this.item.name }); + this.errorMessage = result.errorMessage ?? ''; return; } this.handleInstalledDescriptor(result.descriptor); @@ -331,18 +331,19 @@ export class TbIotHubInstallDialogComponent extends DialogComponent !entry.root && entry.errorMessage && entry.status === InstallPlanEntryStatus.WILL_INSTALL) : undefined; if (failedDependency) { @@ -354,7 +355,8 @@ export class TbIotHubInstallDialogComponent extends DialogComponent 0) { - message += '\n\n' + this.translate.instant('iot-hub.install-rollback-partial'); + const warning = this.translate.instant('iot-hub.install-rollback-partial'); + message = message ? message + '\n\n' + warning : warning; } this.errorMessage = message; return; From 79e1a9ff77dca592fb12085dbd313285137cef53 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Wed, 9 Sep 2026 12:54:04 +0300 Subject: [PATCH 08/39] address the second PE review pass on the install report - rename the cap to MAX_LISTED_NAMES_PER_TYPE: it shortens the printed list, it does not limit what is validated - say how many conflicts a type has in total, and add a note when names were left out, so the "rename or delete them" instruction stays true - keep only the names in the conflict map, the entities were never read for anything else - one way of saying "there are no details" in the dialog, and one comment instead of two that open the same way - cover the whole branch of the cap (10, 11 and 12 names) and the profile name that comes from both the json file and the directory --- .../solutions/DefaultSolutionService.java | 36 ++++++---- .../solutions/DefaultSolutionServiceTest.java | 71 ++++++++++++++----- .../iot-hub-install-dialog.component.ts | 17 +++-- 3 files changed, 82 insertions(+), 42 deletions(-) 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 352d4d4e17..d8ec610c58 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 @@ -182,7 +182,9 @@ public class DefaultSolutionService implements SolutionService { private static final String CONFLICTS_INTRO = "Some entities of the solution template already exist. Rename or delete them and install the template again:"; private static final String RANDOM_PLACEHOLDER = "$random"; - private static final int MAX_REPORTED_CONFLICTS = 10; + private static final int MAX_LISTED_NAMES_PER_TYPE = 10; + private static final String TRUNCATION_NOTE = "Only the first " + MAX_LISTED_NAMES_PER_TYPE + + " names of each type are listed. The rest are reported the next time the template is installed."; @Value("${ui.solution_templates.docs_base_url:https://thingsboard.io/docs}") private String docsBaseUrl; @@ -321,7 +323,7 @@ public class DefaultSolutionService implements SolutionService { }); // Insertion ordered, so that the reported sections keep the order the entities are provisioned in. - Map> conflicts = new LinkedHashMap<>(); + Map> conflicts = new LinkedHashMap<>(); collectRuleChainConflicts(conflicts, tenantId, tempDir, ruleChains); collectConflicts(conflicts, EntityType.DEVICE_PROFILE, deviceProfiles, DeviceProfile::getName, name -> deviceProfileService.findDeviceProfileByName(tenantId, name)); @@ -338,8 +340,11 @@ public class DefaultSolutionService implements SolutionService { return null; } StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); - conflicts.forEach((entityType, entities) -> appendConflicts(details, entityType, - entities.stream().map(entity -> "'" + entity.getName() + "'").toList())); + conflicts.forEach((entityType, names) -> appendConflicts(details, entityType, + names.stream().map(name -> "'" + name + "'").toList())); + if (conflicts.values().stream().anyMatch(names -> names.size() > MAX_LISTED_NAMES_PER_TYPE)) { + details.append(System.lineSeparator()).append(TRUNCATION_NOTE); + } SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); solutionInstallResponse.setSuccess(false); @@ -351,7 +356,7 @@ public class DefaultSolutionService implements SolutionService { * The entity type and the name both come from the definition, so a list can not end up checked against the * wrong type by mistake. */ - private void collectConflicts(Map> conflicts, List definitions, + private void collectConflicts(Map> conflicts, List definitions, Function lookup) { Set checked = new HashSet<>(); for (EntityDefinition definition : definitions) { @@ -361,7 +366,7 @@ public class DefaultSolutionService implements SolutionService { } } - private void collectConflicts(Map> conflicts, EntityType entityType, List definitions, + private void collectConflicts(Map> conflicts, EntityType entityType, List definitions, Function nameExtractor, Function lookup) { Set checked = new HashSet<>(); for (T definition : definitions) { @@ -372,14 +377,14 @@ public class DefaultSolutionService implements SolutionService { } } - private void collectConflict(Map> conflicts, EntityType entityType, String name, + private void collectConflict(Map> conflicts, EntityType entityType, String name, Function lookup) { if (StringUtils.isEmpty(name)) { return; } HasName existing = lookup.apply(name); if (existing != null) { - conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing); + conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing.getName()); } } @@ -387,7 +392,7 @@ public class DefaultSolutionService implements SolutionService { * A rule chain is created from the rule chain file, so both the name and the type of the chain the install will * produce live there - the name in rule_chains.json is only a reference and the type defaults to CORE. */ - private void collectRuleChainConflicts(Map> conflicts, TenantId tenantId, Path tempDir, + private void collectRuleChainConflicts(Map> conflicts, TenantId tenantId, Path tempDir, List definitions) { Set checked = new HashSet<>(); for (ReferenceableEntityDefinition definition : definitions) { @@ -426,13 +431,16 @@ public class DefaultSolutionService implements SolutionService { /** * One markdown list item per entity type, so that the names of the conflicting entities are what the user reads, - * instead of the same sentence repeated for every type. + * instead of the same sentence repeated for every type. Only the first {@value #MAX_LISTED_NAMES_PER_TYPE} + * names of a type are listed, the rest are counted - {@link #TRUNCATION_NOTE} tells the user that the list of + * that type is not complete. */ - private void appendConflicts(StringBuilder details, EntityType entityType, List conflictDescriptions) { + private static void appendConflicts(StringBuilder details, EntityType entityType, List conflictDescriptions) { details.append("- **").append(entityType.getNormalName()).append("**: ") - .append(conflictDescriptions.stream().limit(MAX_REPORTED_CONFLICTS).collect(Collectors.joining(", "))); - if (conflictDescriptions.size() > MAX_REPORTED_CONFLICTS) { - details.append(" and ").append(conflictDescriptions.size() - MAX_REPORTED_CONFLICTS).append(" more"); + .append(conflictDescriptions.stream().limit(MAX_LISTED_NAMES_PER_TYPE).collect(Collectors.joining(", "))); + if (conflictDescriptions.size() > MAX_LISTED_NAMES_PER_TYPE) { + details.append(" and ").append(conflictDescriptions.size() - MAX_LISTED_NAMES_PER_TYPE) + .append(" more (").append(conflictDescriptions.size()).append(" in total)"); } details.append(System.lineSeparator()); } diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index d28955e742..b1b5f1726a 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -18,6 +18,8 @@ package org.thingsboard.server.service.solutions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -61,6 +63,10 @@ class DefaultSolutionServiceTest { private static final String CONFLICTS_INTRO = "Some entities of the solution template already exist. Rename or delete them and install the template again:"; + // mirrors DefaultSolutionService.MAX_LISTED_NAMES_PER_TYPE and the note that goes with it + private static final int LISTED_NAMES_PER_TYPE = 10; + private static final String TRUNCATION_NOTE = "Only the first " + LISTED_NAMES_PER_TYPE + + " names of each type are listed. The rest are reported the next time the template is installed."; private final TenantId tenantId = TenantId.fromUUID(UUID.randomUUID()); @@ -95,15 +101,14 @@ class DefaultSolutionServiceTest { Customer customer = new Customer(); customer.setTitle("Existing customer"); - Device device = new Device(); - device.setName("Existing device"); when(customerService.findCustomerByTenantIdAndTitle(tenantId, "Existing customer")).thenReturn(Optional.of(customer)); Asset asset = new Asset(); asset.setName("Existing asset"); when(assetService.findAssetByTenantIdAndName(tenantId, "Existing asset")).thenReturn(asset); when(assetService.findAssetByTenantIdAndName(tenantId, "New asset")).thenReturn(null); - when(deviceService.findDeviceByTenantIdAndName(tenantId, "Existing device")).thenReturn(device); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "Existing device")) + .thenReturn(existingDevice("Existing device")); when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); @@ -184,9 +189,7 @@ class DefaultSolutionServiceTest { void testValidateSolutionLooksTheSameNameUpOnce() throws IOException { writeEntitiesFile("devices.json", "[{\"name\": \"Sensor\"}, {\"name\": \"Sensor\"}]"); - Device device = new Device(); - device.setName("Sensor"); - when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor")).thenReturn(device); + when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor")).thenReturn(existingDevice("Sensor")); SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); @@ -227,23 +230,47 @@ class DefaultSolutionServiceTest { verifyNoInteractions(deviceService); } - @Test - void testValidateSolutionCapsTheNamesItLists() throws IOException { - String definitions = IntStream.rangeClosed(1, 12) - .mapToObj(i -> "{\"name\": \"Sensor " + i + "\"}") - .collect(Collectors.joining(",")); - writeEntitiesFile("devices.json", "[" + definitions + "]"); - for (int i = 1; i <= 12; i++) { - Device device = new Device(); - device.setName("Sensor " + i); - when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor " + i)).thenReturn(device); + @ParameterizedTest + @ValueSource(ints = {LISTED_NAMES_PER_TYPE, LISTED_NAMES_PER_TYPE + 1, LISTED_NAMES_PER_TYPE + 2}) + void testValidateSolutionListsAtMostTenNamesOfAType(int conflictCount) throws IOException { + List names = IntStream.rangeClosed(1, conflictCount).mapToObj(i -> "Sensor " + i).toList(); + writeEntitiesFile("devices.json", names.stream() + .map(name -> "{\"name\": \"" + name + "\"}") + .collect(Collectors.joining(",", "[", "]"))); + names.forEach(name -> when(deviceService.findDeviceByTenantIdAndName(tenantId, name)) + .thenReturn(existingDevice(name))); + + SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + + int hidden = conflictCount - LISTED_NAMES_PER_TYPE; + String listed = names.stream().limit(LISTED_NAMES_PER_TYPE) + .map(name -> "'" + name + "'").collect(Collectors.joining(", ")); + assertThat(result.getDetails().lines().toList()).contains("- **Device**: " + listed + + (hidden > 0 ? " and " + hidden + " more (" + conflictCount + " in total)" : "")); + if (hidden > 0) { + assertThat(result.getDetails()).contains(TRUNCATION_NOTE); + } else { + assertThat(result.getDetails()).doesNotContain(TRUNCATION_NOTE); } + } + + /** + * The profile lists are the json file plus every file in the directory of the same name merged into one list, so + * this is where the same name genuinely can appear twice. + */ + @Test + void testValidateSolutionChecksAProfileFromBothSourcesOnce() throws IOException { + writeEntitiesFile("device_profiles.json", "[{\"name\": \"Sensor profile\"}]"); + writeFile("device_profiles/sensor_profile.json", "{\"name\": \"Sensor profile\"}"); + + DeviceProfile profile = new DeviceProfile(); + profile.setName("Sensor profile"); + when(deviceProfileService.findDeviceProfileByName(tenantId, "Sensor profile")).thenReturn(profile); SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); - assertThat(result.getDetails().lines().toList()) - .contains("- **Device**: 'Sensor 1', 'Sensor 2', 'Sensor 3', 'Sensor 4', 'Sensor 5', 'Sensor 6', " - + "'Sensor 7', 'Sensor 8', 'Sensor 9', 'Sensor 10' and 2 more"); + assertThat(result.getDetails().lines().toList()).contains("- **Device profile**: 'Sensor profile'"); + verify(deviceProfileService, times(1)).findDeviceProfileByName(tenantId, "Sensor profile"); } @Test @@ -261,6 +288,12 @@ class DefaultSolutionServiceTest { deviceProfileService, assetProfileService, edgeService); } + private static Device existingDevice(String name) { + Device device = new Device(); + device.setName(name); + return device; + } + private void writeFile(String relativePath, String content) throws IOException { Path file = tempDir.resolve(relativePath); Files.createDirectories(file.getParent()); 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 5fe6879e5e..552120b83f 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 @@ -308,7 +308,7 @@ export class TbIotHubInstallDialogComponent extends DialogComponent { if (!result.success) { this.state = 'error'; - this.errorMessage = result.errorMessage ?? ''; + this.errorMessage = result.errorMessage || ''; return; } this.handleInstalledDescriptor(result.descriptor); @@ -338,12 +338,11 @@ export class TbIotHubInstallDialogComponent extends DialogComponent !entry.root && entry.errorMessage && entry.status === InstallPlanEntryStatus.WILL_INSTALL) : undefined; if (failedDependency) { @@ -355,8 +354,8 @@ export class TbIotHubInstallDialogComponent extends DialogComponent 0) { - const warning = this.translate.instant('iot-hub.install-rollback-partial'); - message = message ? message + '\n\n' + warning : warning; + message = [message, this.translate.instant('iot-hub.install-rollback-partial')] + .filter(Boolean).join('\n\n'); } this.errorMessage = message; return; From 27f83a1102a31e4538a092f82f6c720c1f8eead9 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Wed, 9 Sep 2026 13:56:22 +0300 Subject: [PATCH 09/39] name what the install still does not pre-validate The TODO predates the report and most of it is done now - customers, assets, devices, edges, dashboards, rule chains and both profile types are all checked before anything is created. What is left is the entities that still only fail at provision time. --- .../server/service/solutions/DefaultSolutionService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 d8ec610c58..ecdb313639 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 @@ -301,7 +301,8 @@ public class DefaultSolutionService implements SolutionService { } SolutionInstallResponse validateSolution(TenantId tenantId, Path tempDir) { - //TODO: check other entities. + //TODO: pre-validate what still only fails at provision time: customer users (unique by email), + // alarm rules and calculated fields. List ruleChains = loadListOfEntitiesIfFileExists(tempDir, "rule_chains.json", new TypeReference<>() { }); From 99465e283cf8ee97ae722d590e191125f5b00078 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Wed, 9 Sep 2026 15:27:34 +0300 Subject: [PATCH 10/39] quote the names where the conflict is collected The map then holds what the report prints, which leaves appendConflicts a plain pass-through and matches PE, where the entity group descriptions arrive already formatted. --- .../service/solutions/DefaultSolutionService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 ecdb313639..b279d693ef 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 @@ -341,9 +341,8 @@ public class DefaultSolutionService implements SolutionService { return null; } StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); - conflicts.forEach((entityType, names) -> appendConflicts(details, entityType, - names.stream().map(name -> "'" + name + "'").toList())); - if (conflicts.values().stream().anyMatch(names -> names.size() > MAX_LISTED_NAMES_PER_TYPE)) { + conflicts.forEach((entityType, conflictDescriptions) -> appendConflicts(details, entityType, conflictDescriptions)); + if (conflicts.values().stream().anyMatch(descriptions -> descriptions.size() > MAX_LISTED_NAMES_PER_TYPE)) { details.append(System.lineSeparator()).append(TRUNCATION_NOTE); } @@ -385,7 +384,7 @@ public class DefaultSolutionService implements SolutionService { } HasName existing = lookup.apply(name); if (existing != null) { - conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(existing.getName()); + conflicts.computeIfAbsent(entityType, key -> new ArrayList<>()).add(quoted(existing.getName())); } } @@ -430,6 +429,10 @@ public class DefaultSolutionService implements SolutionService { return title.contains(RANDOM_PLACEHOLDER); } + private static String quoted(String value) { + return "'" + value + "'"; + } + /** * One markdown list item per entity type, so that the names of the conflicting entities are what the user reads, * instead of the same sentence repeated for every type. Only the first {@value #MAX_LISTED_NAMES_PER_TYPE} From 33e0cb6619925078d0b1b9f08aa713137bb241e8 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Thu, 10 Sep 2026 13:58:57 +0300 Subject: [PATCH 11/39] Revert "Release EdgeGrpcClient channel on failed connect and guard send/disconnect race" This reverts commit b67fc8dfb1ad1ca22dc076047f8ee37743b894f2. --- .../thingsboard/edge/rpc/EdgeGrpcClient.java | 146 +++++++----------- 1 file changed, 54 insertions(+), 92 deletions(-) diff --git a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java index f96fe8b38f..7e58a2cb9f 100644 --- a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java +++ b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java @@ -86,7 +86,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { private StreamObserver inputStream; - private final ReentrantLock connectionLock = new ReentrantLock(); + private static final ReentrantLock uplinkMsgLock = new ReentrantLock(); @Override public void connect(String edgeKey, @@ -127,38 +127,19 @@ public class EdgeGrpcClient implements EdgeRpcClient { .build()); } - connectionLock.lock(); - try { - channel = builder.build(); - EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); - log.info("[{}] Sending a connect request to the TB!", edgeKey); - this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, channel, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) - .setConnectRequestMsg(ConnectRequestMsg.newBuilder() - .setEdgeRoutingKey(edgeKey) - .setEdgeSecret(edgeSecret) - .setEdgeVersion(getNewestEdgeVersion()) - .setMaxInboundMessageSize(maxInboundMessageSize) - .build()) - .build()); - } catch (RuntimeException e) { - // Release the half-built channel, otherwise every failed reconnect attempt leaks - // its event loops and executors, and the next attempt may not recover at all. - log.error("[{}] Failed to establish the connection, shutting down the channel!", edgeKey, e); - if (channel != null) { - try { - channel.shutdownNow(); - } catch (Exception shutdownEx) { - log.error("[{}] Exception during shutdownNow of the failed channel", edgeKey, shutdownEx); - } - } - channel = null; - inputStream = null; - throw e; - } finally { - connectionLock.unlock(); - } + channel = builder.build(); + EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); + log.info("[{}] Sending a connect request to the TB!", edgeKey); + this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) + .setConnectRequestMsg(ConnectRequestMsg.newBuilder() + .setEdgeRoutingKey(edgeKey) + .setEdgeSecret(edgeSecret) + .setEdgeVersion(getNewestEdgeVersion()) + .setMaxInboundMessageSize(maxInboundMessageSize) + .build()) + .build()); } public static EdgeVersion getNewestEdgeVersion() { @@ -166,7 +147,6 @@ public class EdgeGrpcClient implements EdgeRpcClient { } private StreamObserver initOutputStream(String edgeKey, - ManagedChannel streamChannel, Consumer onUplinkResponse, Consumer onEdgeUpdate, Consumer onDownlink, @@ -186,7 +166,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } else { log.error("[{}] Failed to establish the connection! Code: {}. Error message: {}.", edgeKey, connectResponseMsg.getResponseCode(), connectResponseMsg.getErrorMsg()); try { - EdgeGrpcClient.this.disconnect(true, streamChannel); + EdgeGrpcClient.this.disconnect(true); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -208,7 +188,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { public void onError(Throwable t) { log.warn("[{}] Stream was terminated due to error:", edgeKey, t); try { - EdgeGrpcClient.this.disconnect(true, streamChannel); + EdgeGrpcClient.this.disconnect(true); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -224,95 +204,77 @@ public class EdgeGrpcClient implements EdgeRpcClient { @Override public void disconnect(boolean onError) throws InterruptedException { - disconnect(onError, null); - } - - private void disconnect(boolean onError, ManagedChannel expectedChannel) throws InterruptedException { - ManagedChannel channelToShutdown; - connectionLock.lock(); - try { - // A terminated stream reports its error asynchronously and may lose the race with a - // reconnect: ignore such stale callbacks instead of tearing down the fresh channel. - if (expectedChannel != null && channel != expectedChannel) { - log.info("The channel was already replaced by a reconnect. Skipping disconnect of the stale channel."); - return; - } - if (!onError) { - try { - if (inputStream != null) { - inputStream.onCompleted(); - } - } catch (Exception e) { - log.error("Exception during onCompleted", e); + if (!onError) { + try { + if (inputStream != null) { + inputStream.onCompleted(); } + } catch (Exception e) { + log.error("Exception during onCompleted", e); } - // Clear the references under the lock so that no send can start against a stream - // whose channel is shutting down - such a write leaks the compressed ByteBuf. - inputStream = null; - channelToShutdown = channel; - channel = null; - } finally { - connectionLock.unlock(); } - if (channelToShutdown != null) { - channelToShutdown.shutdown(); + if (channel != null) { + channel.shutdown(); int attempt = 0; do { try { - channelToShutdown.awaitTermination(timeoutSecs, TimeUnit.SECONDS); + channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS); } catch (Exception e) { log.error("Channel await termination was interrupted", e); } if (attempt > 5) { log.warn("We had reached maximum of termination attempts. Force closing channel"); try { - channelToShutdown.shutdownNow(); + channel.shutdownNow(); } catch (Exception e) { log.error("Exception during shutdownNow", e); } break; } attempt++; - } while (!channelToShutdown.isTerminated()); + } while (!channel.isTerminated()); } } @Override public void sendUplinkMsg(UplinkMsg msg) { - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setUplinkMsg(msg) - .build()); + uplinkMsgLock.lock(); + try { + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setUplinkMsg(msg) + .build()); + } finally { + uplinkMsgLock.unlock(); + } } @Override public void sendSyncRequestMsg(boolean fullSyncRequired) { - SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() - .setFullSync(fullSyncRequired) - .build(); - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) - .setSyncRequestMsg(syncRequestMsg) - .build()); + uplinkMsgLock.lock(); + try { + SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() + .setFullSync(fullSyncRequired) + .build(); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) + .setSyncRequestMsg(syncRequestMsg) + .build()); + } finally { + uplinkMsgLock.unlock(); + } } @Override public void sendDownlinkResponseMsg(DownlinkResponseMsg downlinkResponseMsg) { - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setDownlinkResponseMsg(downlinkResponseMsg) - .build()); - } - - private void sendRequestMsg(RequestMsg requestMsg) { - connectionLock.lock(); + uplinkMsgLock.lock(); try { - if (inputStream == null) { - throw new IllegalStateException("Edge is not connected to the cloud. The message is discarded!"); - } - inputStream.onNext(requestMsg); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setDownlinkResponseMsg(downlinkResponseMsg) + .build()); } finally { - connectionLock.unlock(); + uplinkMsgLock.unlock(); } } From 970d590a642ca5d14ab765085f44676f4b18f8b8 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Thu, 10 Sep 2026 15:02:46 +0300 Subject: [PATCH 12/39] Serialize JS script release under evalLock and cover both Nashorn backends --- .../script/NashornJsInvokeServiceTest.java | 5 +- .../script/api/js/NashornJsInvokeService.java | 16 ++- .../NashornJsInvokeServiceLifecycleTest.java | 122 ++++++++++++++++++ 3 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java diff --git a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java index c76eac8c61..1b0ac652b0 100644 --- a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java @@ -231,12 +231,13 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest { void whenScriptIsReleased_thenGlobalPropertyIsRemoved() throws Exception { UUID scriptId = evalScript("return msg;"); String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); - assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("true"); + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).isEqualTo(true); invokeService.release(scriptId).get(); // the property must be deleted, not just set to undefined: an abandoned binding keeps - assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("false"); + // its slot in the Global's PropertyMap forever + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).isEqualTo(false); } @Test diff --git a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java index bb95c60481..32ab55f7ef 100644 --- a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java +++ b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java @@ -144,7 +144,8 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { // that can never be deleted, so every eval/release cycle would grow the Global's PropertyMap // shape history forever. Declaring the function inside an IIFE and assigning it to a global // property keeps the property configurable, allowing doRelease() to actually delete it. - // The prefix stays on the first line so that script line numbers in errors are unchanged. + // The prefix stays on the first line to preserve line numbering on the raw engine path; + // the sandbox beautifier reformats the wrapper and shifts reported error lines anyway. String wrappedScript = "this['" + scriptInfo.getFunctionName() + "'] = (function() { " + jsScript + "\nreturn " + scriptInfo.getFunctionName() + ";\n})();"; return jsExecutor.submit(() -> { @@ -190,10 +191,15 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { protected void doRelease(UUID scriptId, JsScriptInfo scriptInfo) throws ScriptException { String deleteScript = "delete this['" + scriptInfo.getFunctionName() + "'];"; - if (useJsSandbox) { - sandbox.eval(deleteScript); - } else { - engine.eval(deleteScript); + evalLock.lock(); + try { + if (useJsSandbox) { + sandbox.eval(deleteScript); + } else { + engine.eval(deleteScript); + } + } finally { + evalLock.unlock(); } } diff --git a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java new file mode 100644 index 0000000000..cdfd2d8e93 --- /dev/null +++ b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java @@ -0,0 +1,122 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.script.api.js; + +import delight.nashornsandbox.NashornSandbox; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mockito; +import org.springframework.test.util.ReflectionTestUtils; +import org.thingsboard.script.api.ScriptType; +import org.thingsboard.script.api.TbScriptException; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.stats.StatsFactory; + +import javax.script.ScriptEngine; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; + +/** + * Covers the JS global scope lifecycle against both backends the service can be configured with. + * The Spring-wired {@code NashornJsInvokeServiceTest} only exercises the sandbox, since + * {@code js.local.use_js_sandbox} defaults to true. + */ +class NashornJsInvokeServiceLifecycleTest { + + private static final String[] ARG_NAMES = {"msg", "metadata", "msgType"}; + + private NashornJsInvokeService service; + private boolean useJsSandbox; + + @AfterEach + void tearDown() { + if (service != null) { + service.stop(); + } + } + + @ParameterizedTest(name = "useJsSandbox = {0}") + @ValueSource(booleans = {true, false}) + void whenScriptIsReleased_thenGlobalPropertyIsRemovedAndFunctionIsGone(boolean useJsSandbox) throws Exception { + givenService(useJsSandbox); + UUID scriptId = UUID.randomUUID(); + + JsScriptInfo scriptInfo = eval(scriptId, "return {doubled: msg.temperature * 2};"); + assertThat(hasGlobalProperty(scriptInfo)).isTrue(); + assertThat(invoke(scriptId, scriptInfo, "{\"temperature\":21}")).asString().contains("\"doubled\":42"); + + service.doRelease(scriptId); + + assertThat(hasGlobalProperty(scriptInfo)).isFalse(); + assertThatThrownBy(() -> invoke(scriptId, scriptInfo, "{\"temperature\":21}")) + .isInstanceOf(ExecutionException.class) + .cause() + .isInstanceOf(TbScriptException.class); + } + + @ParameterizedTest(name = "useJsSandbox = {0}") + @ValueSource(booleans = {true, false}) + void whenOneOfTwoScriptsIsReleased_thenTheOtherKeepsWorking(boolean useJsSandbox) throws Exception { + givenService(useJsSandbox); + UUID releasedId = UUID.randomUUID(); + UUID retainedId = UUID.randomUUID(); + + JsScriptInfo released = eval(releasedId, "return {v: 1};"); + JsScriptInfo retained = eval(retainedId, "return {v: 2};"); + + service.doRelease(releasedId); + + assertThat(hasGlobalProperty(released)).isFalse(); + assertThat(hasGlobalProperty(retained)).isTrue(); + assertThat(invoke(retainedId, retained, "{}")).asString().contains("\"v\":2"); + } + + private void givenService(boolean useJsSandbox) { + this.useJsSandbox = useJsSandbox; + service = new NashornJsInvokeService(Optional.empty(), Optional.empty()); + ReflectionTestUtils.setField(service, "statsFactory", mock(StatsFactory.class, Mockito.RETURNS_DEEP_STUBS)); + ReflectionTestUtils.setField(service, "useJsSandbox", useJsSandbox); + ReflectionTestUtils.setField(service, "jsExecutorThreadPoolSize", 4); + ReflectionTestUtils.setField(service, "monitorThreadPoolSize", 2); + ReflectionTestUtils.setField(service, "maxCpuTime", 8000L); + ReflectionTestUtils.setField(service, "maxMemory", 104857600L); + service.init(); + } + + private JsScriptInfo eval(UUID scriptId, String scriptBody) throws Exception { + service.doEvalScript(TenantId.SYS_TENANT_ID, ScriptType.RULE_NODE_SCRIPT, scriptBody, scriptId, ARG_NAMES).get(); + return service.scriptInfoMap.get(scriptId); + } + + private Object invoke(UUID scriptId, JsScriptInfo scriptInfo, String msg) throws Exception { + return service.doInvokeFunction(scriptId, scriptInfo, new Object[]{msg, "{}", "POST_TELEMETRY_REQUEST"}).get(); + } + + private boolean hasGlobalProperty(JsScriptInfo scriptInfo) throws Exception { + String expression = "this.hasOwnProperty('" + scriptInfo.getFunctionName() + "')"; + Object result = useJsSandbox + ? ((NashornSandbox) ReflectionTestUtils.getField(service, "sandbox")).eval(expression) + : ((ScriptEngine) ReflectionTestUtils.getField(service, "engine")).eval(expression); + return Boolean.TRUE.equals(result); + } + +} From bd25bee271ecd9ba540022a4b840db1e0f3f059d Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 11 Sep 2026 10:42:54 +0300 Subject: [PATCH 13/39] give the validation a result type of its own validateSolution borrowed SolutionInstallResponse and used null to say that nothing conflicts, so the call site had to test two different ways of saying "go ahead". It returns a SolutionValidationResult now, built through passed() or conflictsFound(report) - the private constructor keeps the two states honest - and the install response is assembled where the install actually answers. --- .../solutions/DefaultSolutionService.java | 23 +++++--- .../data/SolutionValidationResult.java | 43 ++++++++++++++ .../solutions/DefaultSolutionServiceTest.java | 57 +++++++++---------- 3 files changed, 85 insertions(+), 38 deletions(-) create mode 100644 application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java 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 b279d693ef..ad8c6a224b 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 @@ -111,6 +111,7 @@ import org.thingsboard.server.service.solutions.data.DashboardLinkInfo; import org.thingsboard.server.service.solutions.data.DeviceCredentialsInfo; import org.thingsboard.server.service.solutions.data.EdgeLinkInfo; import org.thingsboard.server.service.solutions.data.SolutionInstallContext; +import org.thingsboard.server.service.solutions.data.SolutionValidationResult; import org.thingsboard.server.service.solutions.data.UserCredentialsInfo; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.thingsboard.server.service.solutions.data.definition.AssetDefinition; @@ -257,9 +258,9 @@ public class DefaultSolutionService implements SolutionService { throw new IllegalArgumentException("Solution template is missing solution.json or its 'title' field"); } - SolutionInstallResponse validateResult = validateSolution(tenantId, tempDir); - if (validateResult != null && !validateResult.isSuccess()) { - return validateResult; + SolutionValidationResult validation = validateSolution(tenantId, tempDir); + if (!validation.isPassed()) { + return conflictResponse(validation.getConflictReport()); } return doInstallSolution(user, tenantId, solutionId, tempDir, request); } finally { @@ -300,7 +301,7 @@ public class DefaultSolutionService implements SolutionService { } } - SolutionInstallResponse validateSolution(TenantId tenantId, Path tempDir) { + SolutionValidationResult validateSolution(TenantId tenantId, Path tempDir) { //TODO: pre-validate what still only fails at provision time: customer users (unique by email), // alarm rules and calculated fields. @@ -338,7 +339,7 @@ public class DefaultSolutionService implements SolutionService { collectConflicts(conflicts, edges, name -> edgeService.findEdgeByTenantIdAndName(tenantId, name)); if (conflicts.isEmpty()) { - return null; + return SolutionValidationResult.passed(); } StringBuilder details = new StringBuilder(CONFLICTS_INTRO).append(BLANK_LINE); conflicts.forEach((entityType, conflictDescriptions) -> appendConflicts(details, entityType, conflictDescriptions)); @@ -346,10 +347,14 @@ public class DefaultSolutionService implements SolutionService { details.append(System.lineSeparator()).append(TRUNCATION_NOTE); } - SolutionInstallResponse solutionInstallResponse = new SolutionInstallResponse(); - solutionInstallResponse.setSuccess(false); - solutionInstallResponse.setDetails(details.toString()); - return solutionInstallResponse; + return SolutionValidationResult.conflictsFound(details.toString()); + } + + private static SolutionInstallResponse conflictResponse(String conflictReport) { + SolutionInstallResponse response = new SolutionInstallResponse(); + response.setSuccess(false); + response.setDetails(conflictReport); + return response; } /** diff --git a/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java b/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java new file mode 100644 index 0000000000..407290e487 --- /dev/null +++ b/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java @@ -0,0 +1,43 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.service.solutions.data; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * The outcome of validating a solution template before anything is created: either the install can go ahead, or the + * entities of the tenant the template clashes with, reported as the markdown the install dialog renders. + */ +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public class SolutionValidationResult { + + private static final SolutionValidationResult PASSED = new SolutionValidationResult(true, ""); + + private final boolean passed; + private final String conflictReport; + + public static SolutionValidationResult passed() { + return PASSED; + } + + public static SolutionValidationResult conflictsFound(String conflictReport) { + return new SolutionValidationResult(false, conflictReport); + } + +} diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index b1b5f1726a..860a6d3a0c 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -41,7 +41,7 @@ import org.thingsboard.server.dao.device.DeviceProfileService; import org.thingsboard.server.dao.device.DeviceService; import org.thingsboard.server.dao.edge.EdgeService; import org.thingsboard.server.dao.rule.RuleChainService; -import org.thingsboard.server.service.solutions.data.solution.SolutionInstallResponse; +import org.thingsboard.server.service.solutions.data.SolutionValidationResult; import java.io.IOException; import java.nio.file.Files; @@ -111,18 +111,17 @@ class DefaultSolutionServiceTest { .thenReturn(existingDevice("Existing device")); when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result).isNotNull(); - assertThat(result.isSuccess()).isFalse(); - assertThat(result.getDetails().lines().toList()) + assertThat(result.isPassed()).isFalse(); + assertThat(result.getConflictReport().lines().toList()) .containsSubsequence( CONFLICTS_INTRO, "- **Customer**: 'Existing customer'", "- **Asset**: 'Existing asset'", "- **Device**: 'Existing device'"); // the randomized customer title and the entities that do not exist yet are not reported - assertThat(result.getDetails()) + assertThat(result.getConflictReport()) .doesNotContain("Customer $random") .doesNotContain("New device") .doesNotContain("New asset"); @@ -136,10 +135,10 @@ class DefaultSolutionServiceTest { dashboard.setTitle("Overview"); when(dashboardService.findFirstDashboardInfoByTenantIdAndName(tenantId, "Overview")).thenReturn(dashboard); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result).isNotNull(); - assertThat(result.getDetails().lines().toList()) + assertThat(result.isPassed()).isFalse(); + assertThat(result.getConflictReport().lines().toList()) .containsSubsequence(CONFLICTS_INTRO, "- **Dashboard**: 'Overview'"); } @@ -153,10 +152,10 @@ class DefaultSolutionServiceTest { when(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.CORE, "Name the install creates")) .thenReturn(List.of(ruleChain)); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result).isNotNull(); - assertThat(result.getDetails().lines().toList()) + assertThat(result.isPassed()).isFalse(); + assertThat(result.getConflictReport().lines().toList()) .containsSubsequence(CONFLICTS_INTRO, "- **Rule chain**: 'Name the install creates'"); } @@ -176,10 +175,10 @@ class DefaultSolutionServiceTest { when(assetProfileService.findAssetProfileByName(tenantId, "building")).thenReturn(assetProfile); when(edgeService.findEdgeByTenantIdAndName(tenantId, "Main edge")).thenReturn(edge); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result).isNotNull(); - assertThat(result.getDetails().lines().toList()).containsSubsequence( + assertThat(result.isPassed()).isFalse(); + assertThat(result.getConflictReport().lines().toList()).containsSubsequence( "- **Device profile**: 'thermostat'", "- **Asset profile**: 'building'", "- **Edge**: 'Main edge'"); @@ -191,9 +190,9 @@ class DefaultSolutionServiceTest { when(deviceService.findDeviceByTenantIdAndName(tenantId, "Sensor")).thenReturn(existingDevice("Sensor")); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result.getDetails().lines().toList()).contains("- **Device**: 'Sensor'"); + assertThat(result.getConflictReport().lines().toList()).contains("- **Device**: 'Sensor'"); verify(deviceService, times(1)).findDeviceByTenantIdAndName(tenantId, "Sensor"); } @@ -203,7 +202,7 @@ class DefaultSolutionServiceTest { "{\"name\": \"No name inside\", \"file\": \"nameless.json\"}]"); writeFile("rule_chains/nameless.json", "{\"ruleChain\": {}}"); - assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + assertThat(service.validateSolution(tenantId, tempDir).isPassed()).isTrue(); verifyNoInteractions(ruleChainService); } @@ -217,16 +216,16 @@ class DefaultSolutionServiceTest { when(ruleChainService.findTenantRuleChainsByTypeAndName(tenantId, RuleChainType.EDGE, "Edge chain")) .thenReturn(List.of(ruleChain)); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result.getDetails().lines().toList()).contains("- **Rule chain**: 'Edge chain'"); + assertThat(result.getConflictReport().lines().toList()).contains("- **Rule chain**: 'Edge chain'"); } @Test void testValidateSolutionTreatsAJsonNullFileAsEmpty() throws IOException { writeEntitiesFile("devices.json", "null"); - assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + assertThat(service.validateSolution(tenantId, tempDir).isPassed()).isTrue(); verifyNoInteractions(deviceService); } @@ -240,17 +239,17 @@ class DefaultSolutionServiceTest { names.forEach(name -> when(deviceService.findDeviceByTenantIdAndName(tenantId, name)) .thenReturn(existingDevice(name))); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); int hidden = conflictCount - LISTED_NAMES_PER_TYPE; String listed = names.stream().limit(LISTED_NAMES_PER_TYPE) .map(name -> "'" + name + "'").collect(Collectors.joining(", ")); - assertThat(result.getDetails().lines().toList()).contains("- **Device**: " + listed + assertThat(result.getConflictReport().lines().toList()).contains("- **Device**: " + listed + (hidden > 0 ? " and " + hidden + " more (" + conflictCount + " in total)" : "")); if (hidden > 0) { - assertThat(result.getDetails()).contains(TRUNCATION_NOTE); + assertThat(result.getConflictReport()).contains(TRUNCATION_NOTE); } else { - assertThat(result.getDetails()).doesNotContain(TRUNCATION_NOTE); + assertThat(result.getConflictReport()).doesNotContain(TRUNCATION_NOTE); } } @@ -267,9 +266,9 @@ class DefaultSolutionServiceTest { profile.setName("Sensor profile"); when(deviceProfileService.findDeviceProfileByName(tenantId, "Sensor profile")).thenReturn(profile); - SolutionInstallResponse result = service.validateSolution(tenantId, tempDir); + SolutionValidationResult result = service.validateSolution(tenantId, tempDir); - assertThat(result.getDetails().lines().toList()).contains("- **Device profile**: 'Sensor profile'"); + assertThat(result.getConflictReport().lines().toList()).contains("- **Device profile**: 'Sensor profile'"); verify(deviceProfileService, times(1)).findDeviceProfileByName(tenantId, "Sensor profile"); } @@ -278,12 +277,12 @@ class DefaultSolutionServiceTest { writeEntitiesFile("devices.json", "[{\"name\": \"New device\"}]"); when(deviceService.findDeviceByTenantIdAndName(tenantId, "New device")).thenReturn(null); - assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + assertThat(service.validateSolution(tenantId, tempDir).isPassed()).isTrue(); } @Test void testValidateSolutionWithoutEntityFiles() { - assertThat(service.validateSolution(tenantId, tempDir)).isNull(); + assertThat(service.validateSolution(tenantId, tempDir).isPassed()).isTrue(); verifyNoInteractions(customerService, deviceService, assetService, dashboardService, ruleChainService, deviceProfileService, assetProfileService, edgeService); } From 63387b45b0f61a2b49a91582c44e0ac51ef12f51 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 11 Sep 2026 10:54:57 +0300 Subject: [PATCH 14/39] use the SPDX license header on the new file The base branch switched every header to the SPDX form while this branch was open, so the one file this branch adds was the only one left with the old block comment. --- .../data/SolutionValidationResult.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java b/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java index 407290e487..4b6b07c54b 100644 --- a/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java +++ b/application/src/main/java/org/thingsboard/server/service/solutions/data/SolutionValidationResult.java @@ -1,18 +1,5 @@ -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 package org.thingsboard.server.service.solutions.data; import lombok.AccessLevel; From 04feee5c87f0bfd9e032e20fe2fa21113f5876bb Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 11 Sep 2026 11:07:24 +0300 Subject: [PATCH 15/39] use the SPDX license header on the new test class The base switched every header to the SPDX form yesterday, so the files this branch adds were the only ones left with the old block comment and license:check failed on them once the base was merged in. --- .../server/service/solutions/DefaultSolutionServiceTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index 860a6d3a0c..d34798fe14 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 /** * Copyright © 2016-2026 The Thingsboard Authors * From 5887f01bb362c104db086c5983a3ad5e72141b87 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 11 Sep 2026 11:12:39 +0300 Subject: [PATCH 16/39] drop the old license block left under the SPDX header license:format prepends the header it expects without recognising the block comment the files were created with, so both new files carried the license twice. They now have only the two SPDX lines, the same as every other file that this repository shares with CE. --- .../solutions/DefaultSolutionServiceTest.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java index d34798fe14..d65868a7fb 100644 --- a/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/solutions/DefaultSolutionServiceTest.java @@ -1,20 +1,5 @@ // SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-License-Identifier: Apache-2.0 -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.thingsboard.server.service.solutions; import org.junit.jupiter.api.Test; From 5f3c374036f6b3f30659cd5a07938783ad2a9763 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 14:00:48 +0300 Subject: [PATCH 17/39] Stop installing and deploying boot jars, Windows zips and debs --- TEST_FAST.md | 2 +- msa/pom.xml | 11 ++++----- pom.xml | 65 +++++++++------------------------------------------- 3 files changed, 16 insertions(+), 62 deletions(-) diff --git a/TEST_FAST.md b/TEST_FAST.md index fbea72db9c..28f4b4059a 100644 --- a/TEST_FAST.md +++ b/TEST_FAST.md @@ -42,7 +42,7 @@ Use `-Dpkg.skip=true` to skip all packaging at once (equivalent to all four flag |----------------------------|-------------------------------------------|--------------------------------------------------------------| | `-Dpkg.skip=true` | All of the below (bootjar + deb + rpm + zip) | Yes | | `-Dpkg.skip.bootjar=true` | `spring-boot:repackage` (`*-boot.jar`) | Yes — tests use the regular `.jar`, not the fat boot jar | -| `-Dpkg.skip.deb=true` | Gradle `buildDeb` + Maven `attach-artifact` | Yes — MSA docker modules copy the DEB from `target/` directly | +| `-Dpkg.skip.deb=true` | Gradle `buildDeb` | Yes — MSA docker modules copy the DEB from `target/` directly | | `-Dpkg.skip.rpm=true` | Gradle `buildRpm` | Yes — no test depends on the RPM | | `-Dpkg.skip.zip=true` | `maven-assembly-plugin` Windows ZIP | Yes — no test depends on the ZIP | diff --git a/msa/pom.xml b/msa/pom.xml index 3ffd8ed28b..a44cbbb93c 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -55,10 +55,7 @@ - + skip-deb @@ -71,9 +68,9 @@ none - + skip-pkg diff --git a/pom.xml b/pom.xml index 6ecad4cd2c..0c563899c5 100755 --- a/pom.xml +++ b/pom.xml @@ -34,14 +34,13 @@ Individual flags below can be set independently for finer control. --> false - + false @@ -50,11 +49,6 @@ module depends on the ZIP artifact, so this flag can be toggled freely without breaking downstream modules. --> false - - ${pkg.package.phase} thingsboard ${project.name} /var/log/${pkg.name} @@ -215,26 +209,7 @@ - - - skip-deb - - - pkg.skip.deb - true - - - - none - - - - + skip-pkg @@ -248,7 +223,6 @@ true true true - none @@ -565,6 +539,8 @@ ${pkg.skip.bootjar} ${pkg.mainClass} boot + + false ZIP true true @@ -641,28 +617,9 @@ ${pkg.skip.zip} - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-deb - ${pkg.deb.phase} - - attach-artifact - - - - - ${project.build.directory}/${pkg.name}.deb - deb - deb - - + + false From 87a6f3088181c5a91bcf512af3cc4e4a316d5abd Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 14:02:33 +0300 Subject: [PATCH 18/39] Stop deploying the ui-ngx jar --- ui-ngx/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui-ngx/pom.xml b/ui-ngx/pom.xml index 164ce0d056..42b0fac027 100644 --- a/ui-ngx/pom.xml +++ b/ui-ngx/pom.xml @@ -71,6 +71,14 @@ + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + From 32fb97af7249a34eb9a38a1392713516c4aebb4f Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 21 Aug 2026 15:35:03 +0300 Subject: [PATCH 19/39] Honour skip.yarn in the JS module tests and packaging The yarn test execution in msa/js-executor declared its own skip flag, which overrode the mojo default of ${skip.yarn}, so a build run with -Dskip.yarn=true still invoked yarn run test with no node_modules installed. The two JS packaging modules had the same gap: the ZIP assembly requires a launcher binary produced by yarn run pkg, so it failed on a missing file rather than being skipped along with the yarn work that would have produced it. Both now follow skip.yarn while continuing to honour maven.test.skip. --- msa/js-executor/pom.xml | 26 +++++++++++++++++++++++++- msa/web-ui/pom.xml | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 5d28be03f8..8c35b773db 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -30,6 +30,18 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows + + ${skip.yarn} + + ${skip.yarn} pre-integration-test @@ -112,7 +124,7 @@ test - ${maven.test.skip} + ${yarn.test.skip} --mutex network run test @@ -206,6 +218,18 @@ + + skip-yarn-test + + + maven.test.skip + true + + + + true + + yarn-start diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index b2d148d5b2..f2f5e31309 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -32,6 +32,11 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows + + ${skip.yarn} pre-integration-test From 6172ca8963f6feffe4ddcf80dc079f1dbbdd0e3c Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 21 Aug 2026 15:54:50 +0300 Subject: [PATCH 20/39] Add a skip.ui.build flag that skips only the UI builds frontend-maven-plugin reads skip.yarn on its own, so -Dskip.yarn=true switches off every yarn invocation in the project at once. That is the right shortcut for a local backend build, but it is too blunt for CI: it also silences the msa/js-executor sandbox tests, which are the only yarn-driven tests worth keeping. skip.ui.build is declared once in the root pom and defaults to ${skip.yarn}. It is wired into the frontend-maven-plugin configuration of ui-ngx and msa/web-ui, and into the pkg.skip.zip of msa/web-ui, whose Windows ZIP bundles the launcher that `yarn run pkg` produces. It is deliberately NOT wired into msa/js-executor: with -Dskip.ui.build=true that module still runs its yarn install, its `yarn run pkg` and its sandbox tests. Behaviour: no flags everything builds and is tested as before -Dskip.ui.build=true ui-ngx and msa/web-ui skip; msa/js-executor still builds and runs its tests -Dskip.yarn=true everything skips, exactly as before The element is declared at plugin level rather than per execution so that it also covers the executions contributed by the yarn-build and yarn-start profiles, and so that node/yarn itself is no longer downloaded when there is nothing to run. --- msa/web-ui/pom.xml | 7 +++++-- pom.xml | 7 +++++++ ui-ngx/pom.xml | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index f2f5e31309..93d2ecff76 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -33,10 +33,10 @@ ${project.build.directory}/package/linux ${project.build.directory}/package/windows - ${skip.yarn} + ${skip.ui.build} pre-integration-test @@ -65,6 +65,9 @@ target ${basedir} + + ${skip.ui.build} diff --git a/pom.xml b/pom.xml index 0c563899c5..11c0e52c30 100755 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,13 @@ 17 17 ${basedir} + + ${skip.yarn} none none + ${skip.ui.build} From 21e5d93aeca3ffc038cee2f3290df0a59c86e826 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 15:05:42 +0300 Subject: [PATCH 21/39] Skip all packaging when the UI build is skipped Packages built without the UI are incomplete, so -Dskip.yarn=true and -Dskip.ui.build=true now imply -Dpkg.skip=true through dedicated profiles in the root pom and msa/pom.xml. This replaces the module-level pkg.skip.zip properties in msa/js-executor and msa/web-ui, which shadowed the root skip-pkg profile and made -Dpkg.skip=true build their Windows ZIPs again. --- TEST_FAST.md | 2 ++ msa/js-executor/pom.xml | 5 ----- msa/pom.xml | 25 +++++++++++++++++++++++++ msa/web-ui/pom.xml | 5 ----- pom.xml | 37 ++++++++++++++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/TEST_FAST.md b/TEST_FAST.md index 28f4b4059a..11f8969fca 100644 --- a/TEST_FAST.md +++ b/TEST_FAST.md @@ -46,6 +46,8 @@ Use `-Dpkg.skip=true` to skip all packaging at once (equivalent to all four flag | `-Dpkg.skip.rpm=true` | Gradle `buildRpm` | Yes — no test depends on the RPM | | `-Dpkg.skip.zip=true` | `maven-assembly-plugin` Windows ZIP | Yes — no test depends on the ZIP | +`-Dskip.yarn=true` and `-Dskip.ui.build=true` imply `-Dpkg.skip=true`: packages built without the UI are incomplete. + ## Testcontainers compatibility with the Docker API workaround In case your tests failed to run testcontainers due to unsupported Docker API version diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 8c35b773db..3a4a1ccda4 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -30,11 +30,6 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows - - ${skip.yarn} + + skip-pkg-without-yarn + + + skip.yarn + true + + + + none + + + + skip-pkg-without-ui-build + + + skip.ui.build + true + + + + none + + black-box-tests diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index 93d2ecff76..9e616482cf 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -32,11 +32,6 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows - - ${skip.ui.build} pre-integration-test diff --git a/pom.xml b/pom.xml index 11c0e52c30..77706d1627 100755 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,8 @@ cover msa/js-executor, whose yarn install and sandbox tests keep running. frontend-maven-plugin reads skip.yarn itself, so that property cannot be narrowed to a subset of the modules; this one can, and it defaults to skip.yarn so that - -Dskip.yarn=true still skips every yarn invocation in the project exactly as before. --> + -Dskip.yarn=true still skips every yarn invocation in the project exactly as before. + Either flag also skips all packaging (see the skip-pkg-without-* profiles). --> ${skip.yarn} none none @@ -233,6 +234,40 @@ + + + skip-pkg-without-yarn + + + skip.yarn + true + + + + true + true + true + true + + + + skip-pkg-without-ui-build + + + skip.ui.build + true + + + + true + true + true + true + + + packaging From ccf0581ac38f75461b8dc7511ddce557ef4701b2 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 15:35:28 +0300 Subject: [PATCH 22/39] Generate build-info outside the packaging profile Activating any other root profile (skip-pkg, skip-pkg-without-*) switches off the activeByDefault packaging profile, which held the only build-info execution, so such builds had no build-info.properties and ProjectInfo failed at runtime. The jar plugin config (logback.xml exclusion, manifest) moves out of the profile for the same reason. --- pom.xml | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 77706d1627..0a46f54ab1 100755 --- a/pom.xml +++ b/pom.xml @@ -554,21 +554,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - **/logback.xml - - - - ${pkg.implementationTitle} - ${project.version} - - - - org.springframework.boot spring-boot-maven-plugin @@ -597,7 +582,6 @@ repackage - build-info @@ -717,6 +701,18 @@ org.apache.maven.plugins maven-jar-plugin ${jar-plugin.version} + + + + **/logback.xml + + + + ${pkg.implementationTitle} + ${project.version} + + + org.apache.maven.plugins @@ -727,6 +723,20 @@ org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} + + + + build-info + + build-info + + + + false + + + org.thingsboard From b6227edbc1ea6d7733ea0f74d9b535b7aa8b9a43 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 17:12:32 +0300 Subject: [PATCH 23/39] Version set to 4.2.2.6-SNAPSHOT --- application/pom.xml | 2 +- common/actor/pom.xml | 2 +- common/cache/pom.xml | 2 +- common/cluster-api/pom.xml | 2 +- common/coap-server/pom.xml | 2 +- common/dao-api/pom.xml | 2 +- common/data/pom.xml | 2 +- common/discovery-api/pom.xml | 2 +- common/edge-api/pom.xml | 2 +- common/edge-api/src/main/proto/edge.proto | 1 + common/edqs/pom.xml | 2 +- common/message/pom.xml | 2 +- common/pom.xml | 2 +- common/proto/pom.xml | 2 +- common/queue/pom.xml | 2 +- common/script/pom.xml | 2 +- common/script/remote-js-client/pom.xml | 2 +- common/script/script-api/pom.xml | 2 +- common/stats/pom.xml | 2 +- common/transport/coap/pom.xml | 2 +- common/transport/http/pom.xml | 2 +- common/transport/lwm2m/pom.xml | 2 +- common/transport/mqtt/pom.xml | 2 +- common/transport/pom.xml | 2 +- common/transport/snmp/pom.xml | 2 +- common/transport/transport-api/pom.xml | 2 +- common/util/pom.xml | 2 +- common/version-control/pom.xml | 2 +- dao/pom.xml | 2 +- edqs/pom.xml | 2 +- monitoring/pom.xml | 2 +- msa/black-box-tests/pom.xml | 2 +- msa/edqs/pom.xml | 2 +- msa/js-executor/package.json | 2 +- msa/js-executor/pom.xml | 2 +- msa/monitoring/pom.xml | 2 +- msa/pom.xml | 2 +- msa/tb-node/pom.xml | 2 +- msa/tb/pom.xml | 2 +- msa/transport/coap/pom.xml | 2 +- msa/transport/http/pom.xml | 2 +- msa/transport/lwm2m/pom.xml | 2 +- msa/transport/mqtt/pom.xml | 2 +- msa/transport/pom.xml | 2 +- msa/transport/snmp/pom.xml | 2 +- msa/vc-executor-docker/pom.xml | 2 +- msa/vc-executor/pom.xml | 2 +- msa/web-ui/package.json | 2 +- msa/web-ui/pom.xml | 2 +- netty-mqtt/pom.xml | 4 ++-- pom.xml | 2 +- rest-client/pom.xml | 2 +- rule-engine/pom.xml | 2 +- rule-engine/rule-engine-api/pom.xml | 2 +- rule-engine/rule-engine-components/pom.xml | 2 +- tools/pom.xml | 2 +- transport/coap/pom.xml | 2 +- transport/http/pom.xml | 2 +- transport/lwm2m/pom.xml | 2 +- transport/mqtt/pom.xml | 2 +- transport/pom.xml | 2 +- transport/snmp/pom.xml | 2 +- ui-ngx/package.json | 2 +- ui-ngx/pom.xml | 2 +- 64 files changed, 65 insertions(+), 64 deletions(-) diff --git a/application/pom.xml b/application/pom.xml index ee2b77b4e4..b6a59dba10 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard application diff --git a/common/actor/pom.xml b/common/actor/pom.xml index d715a42ac0..7e6bbe85ff 100644 --- a/common/actor/pom.xml +++ b/common/actor/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/cache/pom.xml b/common/cache/pom.xml index a4c580b5cc..cbfe90440b 100644 --- a/common/cache/pom.xml +++ b/common/cache/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/cluster-api/pom.xml b/common/cluster-api/pom.xml index 7210e5810f..06552c67ae 100644 --- a/common/cluster-api/pom.xml +++ b/common/cluster-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/coap-server/pom.xml b/common/coap-server/pom.xml index 1a4d7b3856..74e2777c4e 100644 --- a/common/coap-server/pom.xml +++ b/common/coap-server/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/dao-api/pom.xml b/common/dao-api/pom.xml index 225fc7230f..e91cb60df1 100644 --- a/common/dao-api/pom.xml +++ b/common/dao-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/data/pom.xml b/common/data/pom.xml index 2801f94153..5b9a8cc97c 100644 --- a/common/data/pom.xml +++ b/common/data/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/discovery-api/pom.xml b/common/discovery-api/pom.xml index 451833d3fa..6b12557443 100644 --- a/common/discovery-api/pom.xml +++ b/common/discovery-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/edge-api/pom.xml b/common/edge-api/pom.xml index e8df15a854..51c96c6f37 100644 --- a/common/edge-api/pom.xml +++ b/common/edge-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/edge-api/src/main/proto/edge.proto b/common/edge-api/src/main/proto/edge.proto index c7c71371e0..cddeb0191a 100644 --- a/common/edge-api/src/main/proto/edge.proto +++ b/common/edge-api/src/main/proto/edge.proto @@ -38,6 +38,7 @@ enum EdgeVersion { V_4_2_2_3 = 4223; V_4_2_2_4 = 4224; V_4_2_2_5 = 4225; + V_4_2_2_6 = 4226; V_LATEST = 99999; } diff --git a/common/edqs/pom.xml b/common/edqs/pom.xml index dd78323862..e61a27a8a8 100644 --- a/common/edqs/pom.xml +++ b/common/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/message/pom.xml b/common/message/pom.xml index e1fe0a464c..417916e518 100644 --- a/common/message/pom.xml +++ b/common/message/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/pom.xml b/common/pom.xml index 0c3a5ba927..c533e1554a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard common diff --git a/common/proto/pom.xml b/common/proto/pom.xml index ed8713b624..7e835835fc 100644 --- a/common/proto/pom.xml +++ b/common/proto/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/queue/pom.xml b/common/queue/pom.xml index 6a682ac6d9..4a340a96ec 100644 --- a/common/queue/pom.xml +++ b/common/queue/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/script/pom.xml b/common/script/pom.xml index c6121aac6c..475151e2a9 100644 --- a/common/script/pom.xml +++ b/common/script/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/script/remote-js-client/pom.xml b/common/script/remote-js-client/pom.xml index d840887124..eac7a8561d 100644 --- a/common/script/remote-js-client/pom.xml +++ b/common/script/remote-js-client/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT script org.thingsboard.common.script diff --git a/common/script/script-api/pom.xml b/common/script/script-api/pom.xml index 9a8da08633..573f4b7ff4 100644 --- a/common/script/script-api/pom.xml +++ b/common/script/script-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT script org.thingsboard.common.script diff --git a/common/stats/pom.xml b/common/stats/pom.xml index a3ae0e3723..771d46eaaf 100644 --- a/common/stats/pom.xml +++ b/common/stats/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/transport/coap/pom.xml b/common/transport/coap/pom.xml index 890cc19a7b..6c05a559b8 100644 --- a/common/transport/coap/pom.xml +++ b/common/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/http/pom.xml b/common/transport/http/pom.xml index 2ec04ce75f..cb27c74bfa 100644 --- a/common/transport/http/pom.xml +++ b/common/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/lwm2m/pom.xml b/common/transport/lwm2m/pom.xml index f9987105d5..271bd9dbc0 100644 --- a/common/transport/lwm2m/pom.xml +++ b/common/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/mqtt/pom.xml b/common/transport/mqtt/pom.xml index 768e8c9b9e..da1fab79aa 100644 --- a/common/transport/mqtt/pom.xml +++ b/common/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/pom.xml b/common/transport/pom.xml index 1a6bbb9c97..949f5da4ba 100644 --- a/common/transport/pom.xml +++ b/common/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/transport/snmp/pom.xml b/common/transport/snmp/pom.xml index 337e707a7e..b372d17b11 100644 --- a/common/transport/snmp/pom.xml +++ b/common/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport diff --git a/common/transport/transport-api/pom.xml b/common/transport/transport-api/pom.xml index 7623b2af19..021ef4ee16 100644 --- a/common/transport/transport-api/pom.xml +++ b/common/transport/transport-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/util/pom.xml b/common/util/pom.xml index a75a5124b6..eaa4edfaf8 100644 --- a/common/util/pom.xml +++ b/common/util/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/version-control/pom.xml b/common/version-control/pom.xml index 0d815961c1..17bf85d869 100644 --- a/common/version-control/pom.xml +++ b/common/version-control/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/dao/pom.xml b/dao/pom.xml index 31101398f1..b67f222401 100644 --- a/dao/pom.xml +++ b/dao/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard dao diff --git a/edqs/pom.xml b/edqs/pom.xml index 77c6cd7cb1..5efc955e57 100644 --- a/edqs/pom.xml +++ b/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard edqs diff --git a/monitoring/pom.xml b/monitoring/pom.xml index 06090c273b..26758d0170 100644 --- a/monitoring/pom.xml +++ b/monitoring/pom.xml @@ -10,7 +10,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index 66b22cbb35..270921ed5e 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/edqs/pom.xml b/msa/edqs/pom.xml index 93ac979d13..6129e3b9ab 100644 --- a/msa/edqs/pom.xml +++ b/msa/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/js-executor/package.json b/msa/js-executor/package.json index e88f5da2eb..fbadae3920 100644 --- a/msa/js-executor/package.json +++ b/msa/js-executor/package.json @@ -1,7 +1,7 @@ { "name": "thingsboard-js-executor", "private": true, - "version": "4.2.2.5", + "version": "4.2.2.6", "description": "ThingsBoard JavaScript Executor Microservice", "main": "server.ts", "bin": "server.js", diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 5d28be03f8..063ad3e14d 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/monitoring/pom.xml b/msa/monitoring/pom.xml index 1d7d16dec5..9566e83d71 100644 --- a/msa/monitoring/pom.xml +++ b/msa/monitoring/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa diff --git a/msa/pom.xml b/msa/pom.xml index 3ffd8ed28b..052102f508 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard msa diff --git a/msa/tb-node/pom.xml b/msa/tb-node/pom.xml index 6bb28e833f..b70e55c691 100644 --- a/msa/tb-node/pom.xml +++ b/msa/tb-node/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/tb/pom.xml b/msa/tb/pom.xml index 41e8b5517d..26061eb43e 100644 --- a/msa/tb/pom.xml +++ b/msa/tb/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/transport/coap/pom.xml b/msa/transport/coap/pom.xml index a7caa361bc..7e04147081 100644 --- a/msa/transport/coap/pom.xml +++ b/msa/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/http/pom.xml b/msa/transport/http/pom.xml index 680b38df3e..ca0ee89f86 100644 --- a/msa/transport/http/pom.xml +++ b/msa/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/lwm2m/pom.xml b/msa/transport/lwm2m/pom.xml index 86d79c322f..6a052bb5de 100644 --- a/msa/transport/lwm2m/pom.xml +++ b/msa/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/mqtt/pom.xml b/msa/transport/mqtt/pom.xml index 15a2f8a3d5..ef9b03e5d1 100644 --- a/msa/transport/mqtt/pom.xml +++ b/msa/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/pom.xml b/msa/transport/pom.xml index 21be0a04b2..650a011502 100644 --- a/msa/transport/pom.xml +++ b/msa/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/transport/snmp/pom.xml b/msa/transport/snmp/pom.xml index 8e154ec5a6..4e3aec5733 100644 --- a/msa/transport/snmp/pom.xml +++ b/msa/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard.msa transport - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT org.thingsboard.msa.transport diff --git a/msa/vc-executor-docker/pom.xml b/msa/vc-executor-docker/pom.xml index e8143ac7c1..7176dc6f8f 100644 --- a/msa/vc-executor-docker/pom.xml +++ b/msa/vc-executor-docker/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/vc-executor/pom.xml b/msa/vc-executor/pom.xml index ed5aa3662a..ebe5da9d4c 100644 --- a/msa/vc-executor/pom.xml +++ b/msa/vc-executor/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/web-ui/package.json b/msa/web-ui/package.json index 4b1e489783..e0099bbdc5 100644 --- a/msa/web-ui/package.json +++ b/msa/web-ui/package.json @@ -1,7 +1,7 @@ { "name": "thingsboard-web-ui", "private": true, - "version": "4.2.2.5", + "version": "4.2.2.6", "description": "ThingsBoard Web UI Microservice", "main": "server.ts", "bin": "server.js", diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index b2d148d5b2..927cd21a1b 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/netty-mqtt/pom.xml b/netty-mqtt/pom.xml index 18bab00e7d..15e2315aeb 100644 --- a/netty-mqtt/pom.xml +++ b/netty-mqtt/pom.xml @@ -8,11 +8,11 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard netty-mqtt - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT jar Netty MQTT Client diff --git a/pom.xml b/pom.xml index 6ecad4cd2c..4b239194a8 100755 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT pom Thingsboard diff --git a/rest-client/pom.xml b/rest-client/pom.xml index d897b1fe27..7477e9bc37 100644 --- a/rest-client/pom.xml +++ b/rest-client/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard rest-client diff --git a/rule-engine/pom.xml b/rule-engine/pom.xml index b6a3a43513..644d72831b 100644 --- a/rule-engine/pom.xml +++ b/rule-engine/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard rule-engine diff --git a/rule-engine/rule-engine-api/pom.xml b/rule-engine/rule-engine-api/pom.xml index fab00e3cb8..faf8b26dac 100644 --- a/rule-engine/rule-engine-api/pom.xml +++ b/rule-engine/rule-engine-api/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT rule-engine org.thingsboard.rule-engine diff --git a/rule-engine/rule-engine-components/pom.xml b/rule-engine/rule-engine-components/pom.xml index 615767fe63..40e1455aa3 100644 --- a/rule-engine/rule-engine-components/pom.xml +++ b/rule-engine/rule-engine-components/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT rule-engine org.thingsboard.rule-engine diff --git a/tools/pom.xml b/tools/pom.xml index fe46969c90..4025cf2b26 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard tools diff --git a/transport/coap/pom.xml b/transport/coap/pom.xml index d104dcf2b9..4cf89f99e0 100644 --- a/transport/coap/pom.xml +++ b/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/http/pom.xml b/transport/http/pom.xml index f7d7d2b472..397c242314 100644 --- a/transport/http/pom.xml +++ b/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/lwm2m/pom.xml b/transport/lwm2m/pom.xml index ca1ec8c822..b87170e421 100644 --- a/transport/lwm2m/pom.xml +++ b/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/mqtt/pom.xml b/transport/mqtt/pom.xml index c26fb8b997..10df97f0b2 100644 --- a/transport/mqtt/pom.xml +++ b/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/pom.xml b/transport/pom.xml index 66e962b674..cb177df37f 100644 --- a/transport/pom.xml +++ b/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard transport diff --git a/transport/snmp/pom.xml b/transport/snmp/pom.xml index 8375236ee4..77e05aa684 100644 --- a/transport/snmp/pom.xml +++ b/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport diff --git a/ui-ngx/package.json b/ui-ngx/package.json index 5358528a6b..c830027a3c 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -1,6 +1,6 @@ { "name": "thingsboard", - "version": "4.2.2.5", + "version": "4.2.2.6", "scripts": { "ng": "ng", "start": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --configuration development --host 0.0.0.0 --open", diff --git a/ui-ngx/pom.xml b/ui-ngx/pom.xml index 164ce0d056..a9324f651c 100644 --- a/ui-ngx/pom.xml +++ b/ui-ngx/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard org.thingsboard From 7fa8edfd0e66acec6b841006dc74b14865224a5f Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 17 Sep 2026 10:05:40 +0300 Subject: [PATCH 24/39] fix: do not clear edge activity state when session moved to another node onEdgeDisconnect persisted active=false based only on this node's in-memory session map. When an edge drops and reconnects to a different TB-Core node, the new node sets active=true while the old node writes active=false whenever it finally notices its dead stream. If the stale write lands last, the edge stays marked inactive while its gRPC session is alive. That flag is not only a status indicator: saveEdgeEvent() consults it before queueing any server-to-edge event, and actions that are not on the offline allowlist - device and entity-group assignments among them - are dropped outright rather than queued. A stale active=false therefore makes assignments silently never reach the edge, with a full "Sync Edge" as the only recovery. - Guard the write with the cluster-wide service-id cache, skipping it only when another node is the recorded owner and that node is still a live TB_CORE service. An absent entry means ownership is unknown, not claimed elsewhere, so that case still persists the inactive state; and a node that died without evicting its claim cannot leave the edge marked active forever. - Publish the ownership claim before writing active=true in onEdgeConnect, so a disconnect callback on the node the edge just left cannot read a stale owner. - Only evict the service-id cache entry when it still points at this node. A stale callback would otherwise wipe the live owner's claim and defeat the guard above for any later disconnect. - Remove the session atomically in onEdgeDisconnect. get() and remove() were not atomic, so a session replaced between the two was dropped from the map, torn down and marked inactive by the stale callback even though it was the live one. LAST_DISCONNECT_TIME and the rule-engine DISCONNECT_EVENT are intentionally left unguarded - they are accurate statements about this session, and the timestamps are the main diagnostic signal for flapping edges. Backport of thingsboard/thingsboard#16155 to lts-4.2, which has no disconnect notification debounce and therefore none of the ownership helpers the 4.3 change builds on; they are introduced here. --- .../service/edge/rpc/EdgeGrpcService.java | 59 ++++- .../service/edge/rpc/EdgeGrpcServiceTest.java | 221 ++++++++++++++++++ 2 files changed, 275 insertions(+), 5 deletions(-) create mode 100644 application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java diff --git a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java index e1211c53a7..9e18ed7e2f 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java @@ -37,6 +37,7 @@ import org.thingsboard.common.util.ThingsBoardExecutors; import org.thingsboard.rule.engine.api.AttributesSaveRequest; import org.thingsboard.rule.engine.api.TimeseriesSaveRequest; import org.thingsboard.server.cache.TbTransactionalCache; +import org.thingsboard.server.cache.TbCacheValueWrapper; import org.thingsboard.server.cluster.TbClusterService; import org.thingsboard.server.common.data.AttributeScope; import org.thingsboard.server.common.data.DataConstants; @@ -58,11 +59,13 @@ import org.thingsboard.server.common.msg.edge.EdgeHighPriorityMsg; import org.thingsboard.server.common.msg.edge.EdgeSessionMsg; import org.thingsboard.server.common.msg.edge.FromEdgeSyncResponse; import org.thingsboard.server.common.msg.edge.ToEdgeSyncRequest; +import org.thingsboard.server.common.msg.queue.ServiceType; import org.thingsboard.server.gen.edge.v1.EdgeRpcServiceGrpc; import org.thingsboard.server.gen.edge.v1.RequestMsg; import org.thingsboard.server.gen.edge.v1.ResponseMsg; import org.thingsboard.server.queue.discovery.TbServiceInfoProvider; import org.thingsboard.server.queue.discovery.TopicService; +import org.thingsboard.server.queue.discovery.PartitionService; import org.thingsboard.server.queue.kafka.KafkaAdmin; import org.thingsboard.server.queue.provider.TbCoreQueueFactory; import org.thingsboard.server.queue.util.AfterStartUp; @@ -152,6 +155,9 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i @Autowired private TbTransactionalCache edgeIdServiceIdCache; + @Autowired + private PartitionService partitionService; + @Autowired private TopicService topicService; @@ -382,10 +388,13 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i } finally { newEventLock.unlock(); } + // Claim ownership before writing the active state, not after: onEdgeDisconnect on the node this edge + // just left reads the cache to decide whether to clear the flag, so publishing the claim first keeps + // it from seeing a stale owner and clearing a state we have already set. + edgeIdServiceIdCache.put(edgeId, serviceInfoProvider.getServiceId()); save(tenantId, edgeId, ACTIVITY_STATE, true); long lastConnectTs = System.currentTimeMillis(); save(tenantId, edgeId, LAST_CONNECT_TIME, lastConnectTs); - edgeIdServiceIdCache.put(edgeId, serviceInfoProvider.getServiceId()); pushRuleEngineMessage(tenantId, edge, lastConnectTs, TbMsgType.CONNECT_EVENT); cancelScheduleEdgeEventsCheck(edgeId); edgeEventsMigrationProcessed.putIfAbsent(edgeId, Boolean.FALSE); @@ -533,8 +542,12 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i EdgeId edgeId = edge.getId(); log.info("[{}][{}] edge disconnected!", edgeId, sessionId); EdgeGrpcSession current = sessions.get(edgeId); - if (current != null && current.getSessionId().equals(sessionId)) { - EdgeGrpcSession toRemove = sessions.remove(edgeId); + // Claim-once removal: get() and remove() are not atomic, so a session that was replaced between the + // two would otherwise be dropped from the map, torn down and marked inactive by this stale callback + // even though it is the live one. Losing the race means this callback owns nothing - fall through to + // the stale-session branch below. + if (current != null && current.getSessionId().equals(sessionId) && sessions.remove(edgeId, current)) { + EdgeGrpcSession toRemove = current; final Lock newEventLock = sessionNewEventsLocks.computeIfAbsent(edgeId, id -> new ReentrantLock()); newEventLock.lock(); try { @@ -545,7 +558,13 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i destroySession(toRemove); sessionsById.remove(sessionId); TenantId tenantId = toRemove.getEdge().getTenantId(); - save(tenantId, edgeId, ACTIVITY_STATE, false); + // A newer session on another node may have already claimed this edge and set active=true. + // Clearing the flag here would leave the edge marked inactive while it is in fact connected, + // which silently drops every downlink event that is not queued for offline edges. + // When ownership is unknown (no cache entry) fall through and persist the inactive state. + if (!isOwnedByAnotherNode(edgeId)) { + save(tenantId, edgeId, ACTIVITY_STATE, false); + } long lastDisconnectTs = System.currentTimeMillis(); save(tenantId, edgeId, LAST_DISCONNECT_TIME, lastDisconnectTs); pushRuleEngineMessage(toRemove.getEdge().getTenantId(), edge, lastDisconnectTs, TbMsgType.DISCONNECT_EVENT); @@ -564,7 +583,37 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i log.debug("[{}] No session found by sessionId [{}] to destroy", edgeId, sessionId); } } - edgeIdServiceIdCache.evict(edgeId); + // Only evict if the cache still points at this node. If the edge already reconnected to another + // TB-Core node, that node has overwritten the entry and owns it - evicting here would wipe the live + // owner's claim and defeat the activity-state guard above. + if (isOwnedByThisNode(edgeId)) { + edgeIdServiceIdCache.evict(edgeId); + } + } + + // The edge's service-id cache entry points at a different node that is still a live TB-Core service. + // Two cases deliberately do NOT count as "owned by another node", so that the caller falls through and + // persists the inactive state: + // - no cache entry: ownership is unknown, not claimed by someone else; + // - entry naming a node that is no longer in the cluster: the edge sessions cache has no TTL by default + // (CACHE_SPECS_EDGE_SESSIONS_TTL=0) and is only ever evicted by the owning node, so a node that died + // without evicting would otherwise keep the edge marked active forever, with no reconciler to correct it. + private boolean isOwnedByAnotherNode(EdgeId edgeId) { + TbCacheValueWrapper wrapper = edgeIdServiceIdCache.get(edgeId); + if (wrapper == null) { + return false; + } + String ownerServiceId = wrapper.get(); + if (ownerServiceId == null || serviceInfoProvider.getServiceId().equals(ownerServiceId)) { + return false; + } + return partitionService.getAllServiceIds(ServiceType.TB_CORE).contains(ownerServiceId); + } + + // The edge's service-id cache entry still points at this node, i.e. this node is the recorded owner. + private boolean isOwnedByThisNode(EdgeId edgeId) { + TbCacheValueWrapper wrapper = edgeIdServiceIdCache.get(edgeId); + return wrapper != null && serviceInfoProvider.getServiceId().equals(wrapper.get()); } private void destroySession(EdgeGrpcSession session) { diff --git a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java new file mode 100644 index 0000000000..7b71c65c9f --- /dev/null +++ b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java @@ -0,0 +1,221 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.service.edge.rpc; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentMatcher; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import org.thingsboard.rule.engine.api.AttributesSaveRequest; +import org.thingsboard.server.cache.SimpleTbCacheValueWrapper; +import org.thingsboard.server.cache.TbTransactionalCache; +import org.thingsboard.server.cluster.TbClusterService; +import org.thingsboard.server.common.data.edge.Edge; +import org.thingsboard.server.common.data.id.EdgeId; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.msg.queue.ServiceType; +import org.thingsboard.server.queue.discovery.PartitionService; +import org.thingsboard.server.queue.discovery.TbServiceInfoProvider; +import org.thingsboard.server.service.edge.EdgeContextComponent; +import org.thingsboard.server.service.telemetry.TelemetrySubscriptionService; + +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.thingsboard.server.service.state.DefaultDeviceStateService.ACTIVITY_STATE; + +@ExtendWith(MockitoExtension.class) +public class EdgeGrpcServiceTest { + + private static final String THIS_NODE = "tb-core-1"; + private static final String OTHER_NODE = "tb-core-2"; + + @Mock + private TbTransactionalCache edgeIdServiceIdCache; + + @Mock + private TbServiceInfoProvider serviceInfoProvider; + + @Mock + private PartitionService partitionService; + + @Mock + private TelemetrySubscriptionService tsSubService; + + @Mock + private TbClusterService clusterService; + + @Mock + private EdgeContextComponent ctx; + + @InjectMocks + private EdgeGrpcService edgeGrpcService; + + private EdgeId edgeId; + private Edge edge; + + @BeforeEach + public void setUp() { + edgeId = new EdgeId(UUID.randomUUID()); + edge = new Edge(edgeId); + edge.setTenantId(TenantId.fromUUID(UUID.randomUUID())); + edge.setName("test-edge"); + } + + // --- activity-state write guard on disconnect --- + + @Test + public void givenEdgeReconnectedToAnotherNode_whenDisconnect_thenInactiveStateNotPersisted() { + // A newer session on another node already set active=true. This stale session's disconnect must not + // clobber it - otherwise the edge stays marked inactive while connected, and the server silently + // drops every assignment event for it. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE, OTHER_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, never()).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenEdgeOwnedByThisNode_whenDisconnect_thenInactiveStateIsPersisted() { + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenNoCacheEntry_whenDisconnect_thenInactiveStateIsPersisted() { + // Ownership unknown (entry absent or expired): keep the pre-guard behaviour, otherwise a genuinely + // disconnected edge would stay marked active forever. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(null); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenOwnerNodeNoLongerInCluster_whenDisconnect_thenInactiveStateIsPersisted() { + // The recorded owner died without evicting its claim. The edge sessions cache has no TTL by default + // and only the owner ever evicts, so honouring a dead claim would leave the edge active forever. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenSessionReplacedDuringDisconnect_whenStaleCallbackRuns_thenLiveSessionKept() { + // Reproduces the get()/remove() interleaving on a single node: onEdgeConnect swaps in a new session + // right after the stale callback's id check passes. The stale callback must not evict or tear down + // the live session, nor clear the activity state. + UUID staleSessionId = UUID.randomUUID(); + EdgeGrpcSession live = mock(EdgeGrpcSession.class); + EdgeGrpcSession stale = mock(EdgeGrpcSession.class); + when(stale.getSessionId()).thenAnswer(invocation -> { + sessions().put(edgeId, live); + return staleSessionId; + }); + sessions().put(edgeId, stale); + + onEdgeDisconnect(staleSessionId); + + assertThat(sessions().get(edgeId)).isSameAs(live); + verify(tsSubService, never()).saveAttributes(argThat(inactiveStateWrite())); + } + + // --- service-id cache eviction guard --- + + @Test + public void givenCacheOwnedByThisNode_whenDisconnect_thenEntryIsEvicted() { + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(edgeIdServiceIdCache, times(1)).evict(edgeId); + } + + @Test + public void givenCacheOwnedByAnotherNode_whenDisconnect_thenEntryIsKept() { + // The edge already reconnected elsewhere: wiping the live owner's claim would defeat the + // activity-state guard for any later disconnect callback. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE, OTHER_NODE)); + + onEdgeDisconnect(sessionId); + + verify(edgeIdServiceIdCache, never()).evict(edgeId); + } + + private void onEdgeDisconnect(UUID sessionId) { + ReflectionTestUtils.invokeMethod(edgeGrpcService, "onEdgeDisconnect", edge, sessionId); + } + + private EdgeGrpcSession sessionFor(UUID sessionId) { + EdgeGrpcSession session = mock(EdgeGrpcSession.class); + when(session.getSessionId()).thenReturn(sessionId); + when(session.getEdge()).thenReturn(edge); + return session; + } + + @SuppressWarnings("unchecked") + private ConcurrentMap sessions() { + return (ConcurrentMap) ReflectionTestUtils.getField(edgeGrpcService, "sessions"); + } + + private ArgumentMatcher inactiveStateWrite() { + return request -> request != null + && edgeId.equals(request.getEntityId()) + && request.getEntries().stream().anyMatch(entry -> + ACTIVITY_STATE.equals(entry.getKey()) + && Boolean.FALSE.equals(entry.getBooleanValue().orElse(null))); + } + +} From 191d7798143120f11e0c44e375d0c9d8099d7028 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:14 +0300 Subject: [PATCH 25/39] Keep IoT Hub markdown table columns from overlapping (#16138) * Keep IoT Hub markdown table columns from overlapping Long unbreakable values in solution instruction tables (logins, e-mails, passwords) overflowed their own column and ran under the copy icon. Cells now break such tokens with overflow-wrap: anywhere, cells holding a copy button reserve room for the icon, and the table is sized by its content instead of splitting the width equally between all columns. * Let preformatted content in markdown table cells wrap With auto layout a cell holding a preformatted block keeps the whole line as its min-content width, which the table cannot shrink below: in a 396px host the table measured 701px and a host that hides horizontal overflow, such as the item detail dialog's .dlg-body, cut the overflow off with no way to scroll to it. Relaxing the block and the code inside it to pre-wrap lets the cell shrink with the table. * Derive the copy icon space in table cells from the icon geometry The 44px reserved on the right of a copy-code cell was derived by hand from the copy icon chip declared 45 lines above it, so nudging the chip's width or offset would silently put the cell text back under the icon. Both numbers now live in $copy-icon-width and $copy-icon-offset, used by the chip itself and by the reservation, which is written as width plus the gap on either side. --- .../iot-hub/iot-hub-markdown.component.scss | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss index 2a946348ad..c25c67e729 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss @@ -3,6 +3,10 @@ $text-color: rgba(0,0,0,0.76); $link-color: #2a7dec; $copy-button-color: #2a7dec; +// Geometry of the copy icon chip, shared by the chip itself and by the space table +// cells reserve for it, so the two cannot drift apart. +$copy-icon-width: 38px; +$copy-icon-offset: 3px; $code-block-border-color: rgba(42, 125, 236, .2); $code-default-color: #212529; @@ -169,10 +173,10 @@ $gallery-border-hover-color: #2a7dec; div { background-color: #fff; position: absolute; - width: 38px; + width: $copy-icon-width; height: 28px; - top: 3px; - right: 3px; + top: $copy-icon-offset; + right: $copy-icon-offset; padding: 8px 10px 0; img { @@ -204,9 +208,30 @@ $gallery-border-hover-color: #2a7dec; } th, td { + // Long unbreakable tokens (logins, e-mails, passwords) must never overflow their + // own column. `anywhere` also drops the cell min-content width down to a single + // character, so auto layout can always squeeze the table into the available + // width instead of overflowing (and getting clipped by `overflow: hidden`). + overflow-wrap: break-word; // fallback for engines without `anywhere` + overflow-wrap: anywhere; + + // Text is not the only thing that can outgrow a column: a preformatted block keeps + // its whole line as min-content width, which auto layout cannot shrink, so the table + // would push past its container and get cut off by a host that hides horizontal + // overflow (iot-hub-item-detail-dialog's .dlg-body). Wrap it inside the cell instead. + // Prism sets `white-space: pre` on both the block and the code inside it, so both + // have to be relaxed for the cell to shrink. + pre, pre > code { + white-space: pre-wrap; + } + div.code-wrapper { display: inline-block; width: 100%; + // Reserve room for the absolutely positioned copy icon, plus the same gap on its + // far side, so the cell text does not run underneath it and the reservation + // follows the chip if its geometry ever changes. + padding-right: $copy-icon-width + 2 * $copy-icon-offset; button.clipboard-btn { top: -6px; @@ -275,11 +300,10 @@ $gallery-border-hover-color: #2a7dec; margin-top: 20px; margin-bottom: 20px; overflow: hidden; - table-layout: fixed; - - &.auto { - table-layout: auto; - } + // Columns are sized to their content: with fixed layout every column got the + // same width, so cells with long values (e-mails, logins, tokens) had to wrap + // mid-word while short columns kept a lot of unused space. + table-layout: auto; > thead { background-color: $table-header-background-color; From 89e2e086fb05980208b62d630e0737bce58c1263 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:29 +0300 Subject: [PATCH 26/39] Refresh the installed items count after an install, update or delete (#16139) * Refresh the installed items count after an install, update or delete The IoT Hub items page loaded its installed-items counter once, so installing, updating or deleting an item from the embedded browse list left the counter showing a stale number until the page was reloaded. The browse component now emits installedItemsChanged whenever it refreshes its own installed-items state, and the page reloads the counter on that event. * Refresh the installed items count from the device wizard and deep links too The device install wizard registers the install as soon as the entity steps finish, but closing it with the header X or with Cancel on a still-pending later step resolved to false, so the caller never reloaded. It now reports 'installed' once the server has the installed item, whichever way it is closed. The deep-linked item dialog is opened by the items page itself, so its outcome was discarded. It now refreshes the browse grid, which in turn announces the new count. --- .../device-install-dialog.component.ts | 9 ++++++++- .../iot-hub/iot-hub-browse.component.ts | 12 +++++++++++- .../iot-hub/iot-hub-items-page.component.html | 3 ++- .../pages/iot-hub/iot-hub-items-page.component.ts | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) 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 676ad706b1..7f991316ee 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 @@ -95,6 +95,12 @@ export class TbDeviceInstallDialogComponent extends DialogComponent = {}; @@ -357,7 +363,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent(); + /** + * Fired whenever an install, update or delete changed what this tenant has installed, so a host + * page showing its own installed-items counter can refresh it instead of waiting for a reload. + */ + @Output() installedItemsChanged = new EventEmitter(); @Input() set activeType(value: ItemType) { if (value && value !== this._activeType) { const wasInit = !!this._activeType; @@ -627,7 +632,11 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy }); } - private reloadInstalledItems(): void { + /** + * Re-reads what is installed for the active type and announces the change. Public so a host page + * that opens the item detail dialog itself can refresh this grid through the same path. + */ + reloadInstalledItems(): void { const config = {ignoreLoading: true}; const pageLink = new PageLink(10000, 0); if (this.activeType === ItemType.WIDGET) { @@ -643,6 +652,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy this.installedItemCounts = counts; }); } + this.installedItemsChanged.emit(); } private loadFilterInfo(): void { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html index 59a42eab29..5787b5ecf0 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html @@ -35,7 +35,8 @@ + [hideTabs]="true" + (installedItemsChanged)="loadInstalledCount()"> diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts index b89448be3c..07beff5559 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts @@ -1,12 +1,13 @@ // SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-License-Identifier: Apache-2.0 -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { map } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service'; +import { TbIotHubBrowseComponent } from '@home/components/iot-hub/iot-hub-browse.component'; import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models'; import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models'; import { PageLink } from '@shared/models/page/page-link'; @@ -83,6 +84,8 @@ export class TbIotHubItemsPageComponent implements OnInit { config: ItemTypePageConfig; installedItemsCount = 0; + @ViewChild(TbIotHubBrowseComponent) private browse: TbIotHubBrowseComponent; + constructor( private route: ActivatedRoute, private router: Router, @@ -109,7 +112,7 @@ export class TbIotHubItemsPageComponent implements OnInit { window.open(this.iotHubApiService.baseUrl + '/signup', '_blank'); } - private loadInstalledCount(): void { + loadInstalledCount(): void { this.iotHubApiService.getInstalledItemsCount(this.config.type, { ignoreLoading: true }).subscribe(count => { this.installedItemsCount = count; }); @@ -147,7 +150,13 @@ export class TbIotHubItemsPageComponent implements OnInit { 'default', true, openItem.preview - ).subscribe(); + ).subscribe(result => { + // The deep-linked dialog is opened by this page rather than by the grid, so its outcome + // has to be fed back in by hand — the grid then refreshes and announces the new count. + if (result === 'installed' || result === 'updated' || result === 'deleted') { + this.browse?.reloadInstalledItems(); + } + }); }); } From b02a7d0817c053f779b54f8e952a62d72e4d8772 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Tue, 22 Sep 2026 16:43:19 +0300 Subject: [PATCH 27/39] Fix license headers --- .../service/edge/rpc/EdgeGrpcServiceTest.java | 17 ++--------------- .../js/NashornJsInvokeServiceLifecycleTest.java | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java index 7b71c65c9f..80730f9f53 100644 --- a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java @@ -1,18 +1,5 @@ -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 package org.thingsboard.server.service.edge.rpc; import org.junit.jupiter.api.BeforeEach; diff --git a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java index cdfd2d8e93..673e06d5a8 100644 --- a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java +++ b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java @@ -1,18 +1,5 @@ -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 package org.thingsboard.script.api.js; import delight.nashornsandbox.NashornSandbox; From d9f5ec7b433854c1682707d4729c5298e6d9f31f Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Thu, 24 Sep 2026 11:11:59 +0200 Subject: [PATCH 28/39] Updated gateway sync branch config --- application/src/main/resources/thingsboard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 2de4c21c8a..a527a4108c 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -1428,7 +1428,7 @@ transport: # URL of gateways dashboard repository repository_url: "${TB_GATEWAY_DASHBOARD_SYNC_REPOSITORY_URL:https://github.com/thingsboard/gateway-management-extensions-dist.git}" # Branch of gateways dashboard repository to work with - branch: "${TB_GATEWAY_DASHBOARD_SYNC_BRANCH:release/4.0.0}" + branch: "${TB_GATEWAY_DASHBOARD_SYNC_BRANCH:release/4.2.0}" # Fetch frequency in hours for gateways dashboard repository fetch_frequency: "${TB_GATEWAY_DASHBOARD_SYNC_FETCH_FREQUENCY:24}" ssl: From d37e0c3506c9df31347127218af5b41443da8640 Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Thu, 24 Sep 2026 22:09:51 +0200 Subject: [PATCH 29/39] Add CARTO as a separate map provider with an optional API key (#16189) * Add API key support for CARTO basemap layers * Move CARTO basemaps to a dedicated map provider and drop legacy HERE v2 credentials - Add MapProvider.carto with its own layer types, settings and TbCartoMapLayer; the API key is optional since CARTO serves tiles without one. - Read CARTO layers stored under the OpenStreetMap provider as CARTO layers (normalized in the layer factory and in the map layers settings form), so existing widgets migrate on the next settings save without an upgrade script. - Reset the API key when switching to CARTO instead of keeping the previous provider's key. - Remove the useV3 toggle and app_id/app_code fields from legacy HERE settings; leaflet-providers 4.x only supports HERE v3 with an API key. --------- Co-authored-by: Vladyslav Prykhodko --- ui-ngx/package.json | 2 +- .../widget/lib/maps-legacy/map-models.ts | 6 -- .../lib/maps-legacy/providers/here-map.ts | 11 ++- .../components/widget/lib/maps/map-layer.ts | 31 +++++++- .../common/map/map-layer-row.component.html | 8 +++ .../common/map/map-layer-row.component.ts | 14 +++- .../map-layer-settings-panel.component.html | 18 ++++- .../map/map-layer-settings-panel.component.ts | 18 ++++- .../common/map/map-layers.component.ts | 5 +- .../here-map-provider-settings.component.html | 23 ++---- .../here-map-provider-settings.component.ts | 34 ++------- .../shared/models/widget/maps/map.models.ts | 72 +++++++++++++++++-- .../assets/locale/locale.constant-en_US.json | 16 +++-- ui-ngx/yarn.lock | 8 +-- 14 files changed, 181 insertions(+), 85 deletions(-) diff --git a/ui-ngx/package.json b/ui-ngx/package.json index c830027a3c..c410d5bed4 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -61,7 +61,7 @@ "jszip": "^3.10.1", "leaflet": "1.9.4", "leaflet-polylinedecorator": "1.6.0", - "leaflet-providers": "2.0.0", + "leaflet-providers": "4.0.0", "leaflet.gridlayer.googlemutant": "0.15.0", "leaflet.markercluster": "1.5.3", "libphonenumber-js": "^1.12.35", diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/map-models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/map-models.ts index b918e859e6..a34f88e9b0 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/map-models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/map-models.ts @@ -121,9 +121,6 @@ export const hereMapProviderTranslationMap = new Map( export interface HereMapProviderSettings { mapProviderHere: HereMapProvider; credentials: { - useV3: boolean; - app_id: string; - app_code: string; apiKey: string; }; } @@ -131,9 +128,6 @@ export interface HereMapProviderSettings { export const defaultHereMapProviderSettings: HereMapProviderSettings = { mapProviderHere: HereMapProvider.hereNormalDay, credentials: { - useV3: true, - app_id: 'AhM6TzD9ThyK78CT3ptx', - app_code: 'p6NPiITB3Vv0GMUFnkLOOg', apiKey: 'kVXykxAfZ6LS4EbCTO02soFVfjA7HoBzNVVH9u7nzoE' } }; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/providers/here-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/providers/here-map.ts index 5afa3c4c6d..64f4f6752b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/providers/here-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps-legacy/providers/here-map.ts @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 import L from 'leaflet'; import LeafletMap from '../leaflet-map'; -import { DEFAULT_ZOOM_LEVEL, WidgetUnitedMapSettings } from '../map-models'; +import { DEFAULT_ZOOM_LEVEL, defaultHereMapProviderSettings, WidgetUnitedMapSettings } from '../map-models'; import { WidgetContext } from '@home/models/widget-component.models'; -import { isDefinedAndNotNull } from '@core/utils'; +import { hereV3Provider } from '@shared/models/widget/maps/map.models'; export class HEREMap extends LeafletMap { constructor(ctx: WidgetContext, $container: HTMLElement, options: WidgetUnitedMapSettings) { @@ -13,11 +13,8 @@ export class HEREMap extends LeafletMap { doubleClickZoom: !this.options.disableDoubleClickZooming, zoomControl: !this.options.disableZoomControl }).setView(options?.parsedDefaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL); - let provider = options.mapProviderHere || 'HERE.normalDay'; - if (options.credentials.useV3 && isDefinedAndNotNull(options.credentials.apiKey)) { - provider = options.mapProviderHere?.replace('HERE', 'HEREv3') || 'HEREv3.normalDay'; - } - const tileLayer = (L.tileLayer as any).provider(provider, options.credentials); + const apiKey = options.credentials?.apiKey || defaultHereMapProviderSettings.credentials.apiKey; + const tileLayer = L.tileLayer.provider(hereV3Provider(options.mapProviderHere), {apiKey}); tileLayer.addTo(map); super.setMap(map); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-layer.ts index a79f290c9b..d61e81ca6e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-layer.ts @@ -1,7 +1,9 @@ // SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-License-Identifier: Apache-2.0 import { + CartoMapLayerSettings, CustomMapLayerSettings, + defaultCartoMapLayerSettings, defaultCustomMapLayerSettings, defaultGoogleMapLayerSettings, defaultHereMapLayerSettings, @@ -10,8 +12,10 @@ import { defaultTencentMapLayerSettings, GoogleMapLayerSettings, HereMapLayerSettings, + hereV3Provider, MapLayerSettings, MapProvider, + normalizeMapLayerSettings, OpenStreetMapLayerSettings, ReferenceLayerType, TencentMapLayerSettings, WEBGL_ERROR_EVENT @@ -46,9 +50,12 @@ export abstract class TbMapLayer { static fromSettings(ctx: WidgetContext, inputSettings: DeepPartial) { + inputSettings = normalizeMapLayerSettings(inputSettings as MapLayerSettings); switch (inputSettings.provider) { case MapProvider.openstreet: return new TbOpenStreetMapLayer(ctx, inputSettings); + case MapProvider.carto: + return new TbCartoMapLayer(ctx, inputSettings); case MapProvider.google: return new TbGoogleMapLayer(ctx, inputSettings); case MapProvider.tencent: @@ -212,6 +219,24 @@ class TbOpenStreetMapLayer extends TbMapLayer { } +class TbCartoMapLayer extends TbMapLayer { + + constructor(protected ctx: WidgetContext, + protected inputSettings: DeepPartial) { + super(ctx, inputSettings); + } + + protected defaultSettings(): CartoMapLayerSettings { + return defaultCartoMapLayerSettings; + } + + protected createLayer(): Observable { + const layer = L.tileLayer.provider(this.settings.layerType, {apikey: this.settings.apiKey || ''}); + return of(layer); + } + +} + class TbGoogleMapLayer extends TbMapLayer { static loadedApiKeysGlobal: {[key: string]: boolean} = {}; @@ -293,7 +318,7 @@ class TbHereMapLayer extends TbMapLayer { protected createLayer(): Observable { const apiKey = this.settings.apiKey || defaultHereMapLayerSettings.apiKey; - const layer = L.tileLayer.provider(this.settings.layerType, {useV3: true, apiKey} as any); + const layer = L.tileLayer.provider(hereV3Provider(this.settings.layerType), {apiKey}); return of(layer); } @@ -311,7 +336,9 @@ class TbCustomMapLayer extends TbMapLayer { } protected createLayer(): Observable { - const layer = L.tileLayer(this.settings.tileUrl); + const layer = L.tileLayer(this.settings.tileUrl, this.settings.customAttribution ? { + attribution: this.settings.customAttribution + } : undefined); return of(layer); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.html index e19007a1e5..02ddc00901 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.html @@ -23,6 +23,14 @@ + + + + {{ cartoLayerTranslationMap.get(layerType) | translate }} + + + diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.ts index 9680188046..93ed9be3f1 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-row.component.ts @@ -25,6 +25,8 @@ import { TbPopoverService } from '@shared/components/popover.service'; import { TranslateService } from '@ngx-translate/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { + cartoLayerTranslationMap, + cartoLayerTypes, defaultLayerTitle, defaultMapLayerSettings, googleMapLayerTranslationMap, @@ -35,6 +37,8 @@ import { MapProvider, mapProviders, mapProviderTranslationMap, + mapProviderHasApiKey, + mapProviderRequiresApiKey, openStreetLayerTypes, openStreetMapLayerTranslationMap, tencentLayerTranslationMap, @@ -71,6 +75,10 @@ export class MapLayerRowComponent implements ControlValueAccessor, OnInit { openStreetMapLayerTranslationMap = openStreetMapLayerTranslationMap; + cartoLayerTypes = cartoLayerTypes; + + cartoLayerTranslationMap = cartoLayerTranslationMap; + googleMapLayerTypes = googleMapLayerTypes; googleMapLayerTranslationMap = googleMapLayerTranslationMap; @@ -110,6 +118,7 @@ export class MapLayerRowComponent implements ControlValueAccessor, OnInit { provider: [null, [Validators.required]], layerType: [null, [Validators.required]], tileUrl: [null, [Validators.required]], + customAttribution: [null, []], apiKey: [null, [Validators.required]], referenceLayer: [null, []] }); @@ -202,12 +211,15 @@ export class MapLayerRowComponent implements ControlValueAccessor, OnInit { const provider: MapProvider = this.layerFormGroup.get('provider').value; if (provider === MapProvider.custom) { this.layerFormGroup.get('tileUrl').enable({emitEvent: false}); + this.layerFormGroup.get('customAttribution').enable({emitEvent: false}); this.layerFormGroup.get('layerType').disable({emitEvent: false}); } else { this.layerFormGroup.get('tileUrl').disable({emitEvent: false}); + this.layerFormGroup.get('customAttribution').disable({emitEvent: false}); this.layerFormGroup.get('layerType').enable({emitEvent: false}); } - if ([MapProvider.google, MapProvider.here].includes(provider)) { + if (mapProviderHasApiKey(provider)) { + this.layerFormGroup.get('apiKey').setValidators(mapProviderRequiresApiKey(provider) ? [Validators.required] : []); this.layerFormGroup.get('apiKey').enable({emitEvent: false}); } else { this.layerFormGroup.get('apiKey').disable({emitEvent: false}); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.html index cdf24fd07c..a65dc5bf18 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.html @@ -33,6 +33,14 @@ + + + + {{ cartoLayerTranslationMap.get(layerType) | translate }} + + + @@ -62,12 +70,18 @@ -
+
+
widgets.maps.layer.provider.custom.attribution
+ + + +
+
widgets.maps.layer.credentials.credentials
widgets.maps.layer.credentials.api-key
- +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts index bddca3f360..5e4866df9c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts @@ -5,6 +5,8 @@ import { TbPopoverComponent } from '@shared/components/popover.component'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { + cartoLayerTranslationMap, + cartoLayerTypes, defaultLayerTitle, defaultMapLayerSettings, googleMapLayerTranslationMap, @@ -15,6 +17,8 @@ import { MapProvider, mapProviders, mapProviderTranslationMap, + mapProviderHasApiKey, + mapProviderRequiresApiKey, openStreetLayerTypes, openStreetMapLayerTranslationMap, referenceLayerTypes, referenceLayerTypeTranslationMap, tencentLayerTranslationMap, @@ -42,6 +46,10 @@ export class MapLayerSettingsPanelComponent implements OnInit { openStreetMapLayerTranslationMap = openStreetMapLayerTranslationMap; + cartoLayerTypes = cartoLayerTypes; + + cartoLayerTranslationMap = cartoLayerTranslationMap; + googleMapLayerTypes = googleMapLayerTypes; googleMapLayerTranslationMap = googleMapLayerTranslationMap; @@ -81,6 +89,7 @@ export class MapLayerSettingsPanelComponent implements OnInit { provider: [null, [Validators.required]], layerType: [null, [Validators.required]], tileUrl: [null, [Validators.required]], + customAttribution: [null, []], apiKey: [null, [Validators.required]], referenceLayer: [null, []] } @@ -108,6 +117,10 @@ export class MapLayerSettingsPanelComponent implements OnInit { return this.translate.instant(translationKey); } + hasApiKey(): boolean { + return mapProviderHasApiKey(this.layerFormGroup.get('provider').value); + } + applyLayerSettings() { const layerSettings: MapLayerSettings = this.layerFormGroup.value; this.mapLayerSettingsApplied.emit(layerSettings); @@ -126,12 +139,15 @@ export class MapLayerSettingsPanelComponent implements OnInit { const provider: MapProvider = this.layerFormGroup.get('provider').value; if (provider === MapProvider.custom) { this.layerFormGroup.get('tileUrl').enable({emitEvent: false}); + this.layerFormGroup.get('customAttribution').enable({emitEvent: false}); this.layerFormGroup.get('layerType').disable({emitEvent: false}); } else { this.layerFormGroup.get('tileUrl').disable({emitEvent: false}); + this.layerFormGroup.get('customAttribution').disable({emitEvent: false}); this.layerFormGroup.get('layerType').enable({emitEvent: false}); } - if ([MapProvider.google, MapProvider.here].includes(provider)) { + if (mapProviderHasApiKey(provider)) { + this.layerFormGroup.get('apiKey').setValidators(mapProviderRequiresApiKey(provider) ? [Validators.required] : []); this.layerFormGroup.get('apiKey').enable({emitEvent: false}); } else { this.layerFormGroup.get('apiKey').disable({emitEvent: false}); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layers.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layers.component.ts index d6ac020c42..a73c9bfbb5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layers.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layers.component.ts @@ -20,7 +20,8 @@ import { MapLayerSettings, mapLayerValid, mapLayerValidator, - MapProvider + MapProvider, + normalizeMapLayerSettings } from '@shared/models/widget/maps/map.models'; @Component({ @@ -93,7 +94,7 @@ export class MapLayersComponent implements ControlValueAccessor, OnInit, Validat } writeValue(value: MapLayerSettings[] | undefined): void { - const layers: MapLayerSettings[] = value || []; + const layers: MapLayerSettings[] = (value || []).map(layer => normalizeMapLayerSettings(layer)); this.layersFormGroup.setControl('layers', this.prepareLayersFormArray(layers), {emitEvent: false}); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.html index d95bb0daa3..2131e54bdf 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.html @@ -16,25 +16,10 @@
widgets.maps.credentials - - {{ 'widgets.maps.here-use-new-version-api-3' | translate }} - -
- - widgets.maps.here-app-id - - - - widgets.maps.here-app-code - - -
- - - widgets.maps.here-api-key - - - + + widgets.maps.here-api-key + +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.ts index 823840b624..14d5236473 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/here-map-provider-settings.component.ts @@ -16,11 +16,11 @@ import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { TranslateService } from '@ngx-translate/core'; import { + defaultHereMapProviderSettings, HereMapProvider, HereMapProviderSettings, hereMapProviderTranslationMap } from '@home/components/widget/lib/maps-legacy/map-models'; -import { isDefinedAndNotNull } from '@core/utils'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Component({ @@ -67,25 +67,9 @@ export class HereMapProviderSettingsComponent extends PageComponent implements O this.providerSettingsFormGroup = this.fb.group({ mapProviderHere: [null, [Validators.required]], credentials: this.fb.group({ - useV3: [true], - app_id: [null, [Validators.required]], - app_code: [null, [Validators.required]], apiKey: [null, [Validators.required]] }) }); - this.providerSettingsFormGroup.get('credentials.useV3').valueChanges.pipe( - takeUntilDestroyed(this.destroyRef) - ).subscribe(value => { - if (value) { - this.providerSettingsFormGroup.get('credentials.apiKey').enable({emitEvent: false}); - this.providerSettingsFormGroup.get('credentials.app_id').disable({emitEvent: false}); - this.providerSettingsFormGroup.get('credentials.app_code').disable({emitEvent: false}); - } else { - this.providerSettingsFormGroup.get('credentials.apiKey').disable({emitEvent: false}); - this.providerSettingsFormGroup.get('credentials.app_id').enable({emitEvent: false}); - this.providerSettingsFormGroup.get('credentials.app_code').enable({emitEvent: false}); - } - }); this.providerSettingsFormGroup.valueChanges.pipe( takeUntilDestroyed(this.destroyRef) ).subscribe(() => { @@ -106,21 +90,17 @@ export class HereMapProviderSettingsComponent extends PageComponent implements O this.providerSettingsFormGroup.disable({emitEvent: false}); } else { this.providerSettingsFormGroup.enable({emitEvent: false}); - this.providerSettingsFormGroup.get('credentials.useV3').updateValueAndValidity({onlySelf: true}); } } writeValue(value: HereMapProviderSettings): void { - if (!isDefinedAndNotNull(value.credentials.useV3)) { - if (isDefinedAndNotNull(value.credentials.app_id) && isDefinedAndNotNull(value.credentials.app_code)) { - value.credentials.useV3 = false; - } - } this.modelValue = value; - this.providerSettingsFormGroup.patchValue( - value, {emitEvent: false} - ); - this.providerSettingsFormGroup.get('credentials.useV3').updateValueAndValidity({onlySelf: true}); + this.providerSettingsFormGroup.patchValue({ + mapProviderHere: value?.mapProviderHere, + credentials: { + apiKey: value?.credentials?.apiKey || defaultHereMapProviderSettings.credentials.apiKey + } + }, {emitEvent: false}); } public validate(c: FormControl) { diff --git a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts index 3271c3dc36..a3dbcf63bc 100644 --- a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts +++ b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts @@ -832,6 +832,7 @@ export const defaultMapActionButtonSettings: MapActionButtonSettings = { export enum MapProvider { openstreet = 'openstreet', + carto = 'carto', google = 'google', here = 'here', tencent = 'tencent', @@ -843,6 +844,7 @@ export const mapProviders = Object.keys(MapProvider) as MapProvider[]; export const mapProviderTranslationMap = new Map( [ [MapProvider.openstreet, 'widgets.maps.layer.provider.openstreet.title'], + [MapProvider.carto, 'widgets.maps.layer.provider.carto.title'], [MapProvider.google, 'widgets.maps.layer.provider.google.title'], [MapProvider.here, 'widgets.maps.layer.provider.here.title'], [MapProvider.tencent, 'widgets.maps.layer.provider.tencent.title'], @@ -880,6 +882,9 @@ export const mapLayerValid = (layer: MapLayerSettings): boolean => { case MapProvider.openstreet: const openStreetLayer = layer as OpenStreetMapLayerSettings; return !!openStreetLayer.layerType; + case MapProvider.carto: + const cartoLayer = layer as CartoMapLayerSettings; + return !!cartoLayer.layerType; case MapProvider.google: const googleLayer = layer as GoogleMapLayerSettings; return !!googleLayer.layerType; @@ -913,6 +918,9 @@ export const defaultLayerTitle = (layer: MapLayerSettings): string => { case MapProvider.openstreet: const openStreetLayer = layer as OpenStreetMapLayerSettings; return openStreetMapLayerTranslationMap.get(openStreetLayer.layerType); + case MapProvider.carto: + const cartoLayer = layer as CartoMapLayerSettings; + return cartoLayerTranslationMap.get(cartoLayer.layerType); case MapProvider.google: const googleLayer = layer as GoogleMapLayerSettings; return googleMapLayerTranslationMap.get(googleLayer.layerType); @@ -932,9 +940,7 @@ export enum OpenStreetLayerType { openStreetHot = 'OpenStreetMap.HOT', esriWorldStreetMap = 'Esri.WorldStreetMap', esriWorldTopoMap = 'Esri.WorldTopoMap', - esriWorldImagery = 'Esri.WorldImagery', - cartoDbPositron = 'CartoDB.Positron', - cartoDbDarkMatter = 'CartoDB.DarkMatter' + esriWorldImagery = 'Esri.WorldImagery' } export const openStreetLayerTypes = Object.values(OpenStreetLayerType) as OpenStreetLayerType[]; @@ -945,9 +951,7 @@ export const openStreetMapLayerTranslationMap = new Map( + [ + [CartoLayerType.cartoPositron, 'widgets.maps.layer.provider.carto.positron'], + [CartoLayerType.cartoDarkMatter, 'widgets.maps.layer.provider.carto.dark-matter'] + ] +); + +export interface CartoMapLayerSettings extends MapLayerSettings { + provider: MapProvider.carto; + layerType: CartoLayerType; + apiKey?: string; +} + +export const defaultCartoMapLayerSettings: CartoMapLayerSettings = { + provider: MapProvider.carto, + layerType: CartoLayerType.cartoPositron, + apiKey: null +} + export enum GoogleLayerType { roadmap = 'roadmap', satellite = 'satellite', @@ -1021,6 +1051,16 @@ export const defaultHereMapLayerSettings: HereMapLayerSettings = { apiKey: 'kVXykxAfZ6LS4EbCTO02soFVfjA7HoBzNVVH9u7nzoE' } +const hereV3Variants: {[v2Variant: string]: string} = { + normalDay: 'exploreDay', + normalNight: 'exploreNight', + hybridDay: 'exploreSatelliteDay', + terrainDay: 'topoDay' +}; + +export const hereV3Provider = (layerType: string): string => + `HERE.${hereV3Variants[layerType?.split('.')[1]] || hereV3Variants.normalDay}`; + export enum TencentLayerType { tencentNormal = 'Tencent.Normal', tencentSatellite = 'Tencent.Satellite', @@ -1050,6 +1090,7 @@ export const defaultTencentMapLayerSettings: TencentMapLayerSettings = { export interface CustomMapLayerSettings extends MapLayerSettings { provider: MapProvider.custom; tileUrl: string; + customAttribution?: string; } export const defaultCustomMapLayerSettings: CustomMapLayerSettings = { @@ -1057,10 +1098,29 @@ export const defaultCustomMapLayerSettings: CustomMapLayerSettings = { tileUrl: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' } +export const mapProviderHasApiKey = (provider: MapProvider): boolean => + [MapProvider.carto, MapProvider.google, MapProvider.here].includes(provider); + +export const mapProviderRequiresApiKey = (provider: MapProvider): boolean => + [MapProvider.google, MapProvider.here].includes(provider); + +const legacyOpenStreetCartoLayerTypes = new Set(cartoLayerTypes); + +// CARTO layers used to be stored under the OpenStreetMap provider, keep reading them as CARTO layers +export const normalizeMapLayerSettings = (layer: MapLayerSettings): MapLayerSettings => { + if (layer?.provider === MapProvider.openstreet && + legacyOpenStreetCartoLayerTypes.has((layer as OpenStreetMapLayerSettings).layerType)) { + return {...layer, provider: MapProvider.carto}; + } + return layer; +}; + export const defaultMapLayerSettings = (provider: MapProvider): MapLayerSettings => { switch (provider) { case MapProvider.openstreet: return defaultOpenStreetMapLayerSettings; + case MapProvider.carto: + return defaultCartoMapLayerSettings; case MapProvider.google: return defaultGoogleMapLayerSettings; case MapProvider.here: 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 b5f51fd6d4..b3aa95d6ec 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -8563,9 +8563,12 @@ "hot": "HOT", "esri-street": "WorldStreetMap", "esri-topo": "WorldTopoMap", - "esri-imagery": "WorldImagery", - "cartodb-positron": "Positron", - "cartodb-dark-matter": "DarkMatter" + "esri-imagery": "WorldImagery" + }, + "carto": { + "title": "CARTO", + "positron": "Positron", + "dark-matter": "DarkMatter" }, "google": { "title": "Google", @@ -8589,7 +8592,9 @@ }, "custom": { "title": "Custom", - "tile-url": "Tile URL" + "tile-url": "Tile URL", + "attribution": "Copyright text", + "attribution-hint": "Displayed at the bottom of the map. Required by most tile providers." } }, "credentials": { @@ -8866,10 +8871,7 @@ "here-map-hybrid-day": "HERE.hybridDay", "here-map-terrain-day": "HERE.terrainDay", "credentials": "Credentials", - "here-app-id": "HERE app id", - "here-app-code": "HERE app code", "here-api-key": "HERE API key", - "here-use-new-version-api-3": "Use API version 3", "tencent-maps-api-key": "Tencent Maps API Key", "tencent-map-type-roadmap": "Roadmap", "tencent-map-type-satelite": "Satellite", diff --git a/ui-ngx/yarn.lock b/ui-ngx/yarn.lock index 7d184f78dc..9b6453cd01 100644 --- a/ui-ngx/yarn.lock +++ b/ui-ngx/yarn.lock @@ -7576,10 +7576,10 @@ leaflet-polylinedecorator@1.6.0: dependencies: leaflet-rotatedmarker "^0.2.0" -leaflet-providers@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/leaflet-providers/-/leaflet-providers-2.0.0.tgz#dfdab9ca2dccc57c79e1462bc3dd20f78910afcb" - integrity sha512-CWwKEnHd66Qsx0m4o5q5ZOa60s00B91pMxnlr4Y22msubfs7dhbZhdMIz8bvZQkrZqi67ppI1fsZRS6vtrLcOA== +leaflet-providers@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/leaflet-providers/-/leaflet-providers-4.0.0.tgz#a98c5631a671c366739d8658e40be1d02e2c57cb" + integrity sha512-4m3Q4t0e+cHVNIPzlkW9HFWEgplImFRv8cnUFJYOfFoS6p2KosAfmh2Do6qk4HMdqutqbHMpv3F7sn/CUSw6oQ== leaflet-rotatedmarker@^0.2.0: version "0.2.0" From 84c1cfb26aca80d024738e4a8feaa718d7f05008 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 25 Sep 2026 09:26:37 +0300 Subject: [PATCH 30/39] Bump jackson-bom from 2.21.5 to 2.21.6 to fix CVE-2026-68497 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a1136afd0f..37e3afe09f 100755 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 10.1.59 5.4.3 1.5.38 - 2.21.5 + 2.21.6 42.7.12 5.33.1 5.6.4 From 6e3818f83374ed17728c70cbdf3faba15603ea74 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 25 Sep 2026 09:26:37 +0300 Subject: [PATCH 31/39] Bump amqp-client from 5.33.1 to 5.34.0 to fix CVE-2026-75516 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 37e3afe09f..157cd042ea 100755 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ 1.5.38 2.21.6 42.7.12 - 5.33.1 + 5.34.0 5.6.4 2.4.0-b180830.0359 0.12.5 From b16701288fde7d67bcd69c6107d803d6007735b2 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 25 Sep 2026 09:26:37 +0300 Subject: [PATCH 32/39] Bump wire-schema from 6.3.0 to 6.4.5 to fix CVE-2026-63126 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 157cd042ea..76b2c8ae4d 100755 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ 1.11.0 4.4 1.0.4TB - 6.3.0 + 6.4.5 10.1.3 3.7.4 4.0.2 From ebebc194cbb8b54728322b1f9a64e371809370e3 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 25 Sep 2026 10:28:38 +0300 Subject: [PATCH 33/39] Bump zstd-jni from 1.5.6-4 to 1.5.7-14 to fix CVE-2026-87795, CVE-2026-87823, and 5 others --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 76b2c8ae4d..db90bce5f5 100755 --- a/pom.xml +++ b/pom.xml @@ -77,6 +77,7 @@ 42.7.12 5.34.0 5.6.4 + 1.5.7-14 2.4.0-b180830.0359 0.12.5 0.10 @@ -1114,6 +1115,13 @@ ${httpclient5.version} + + + com.github.luben + zstd-jni + ${zstd-jni.version} + + org.springframework.boot spring-boot-dependencies From 0bc466a165c755fa8ce221665df1b1a8f28164ec Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 25 Sep 2026 10:45:58 +0300 Subject: [PATCH 34/39] Bump npm dependencies to fix CVE-2026-90711, CVE-2026-17495, CVE-2026-87776, and CVE-2026-84375 - proxy-addr 2.0.7 -> 2.0.8 (CVE-2026-90711, GHSA-jqcg-44mw-7w3h) - moment 2.30.1 -> 2.31.0 (CVE-2026-17495, GHSA-4p3w-j4w9-5jqw) - compression 1.8.1 -> 1.8.2 (CVE-2026-87776, GHSA-vc2v-76pw-4v95) - js-yaml 4.3.1 -> 4.3.2 in ui-ngx (CVE-2026-84375, GHSA-2883-xcg3-v3hh) --- msa/js-executor/yarn.lock | 12 ++++++------ msa/web-ui/package.json | 2 +- msa/web-ui/yarn.lock | 26 ++++++++++++++++---------- ui-ngx/package.json | 2 +- ui-ngx/yarn.lock | 27 ++++++++++++++------------- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/msa/js-executor/yarn.lock b/msa/js-executor/yarn.lock index e4f6409a3d..bb1095b947 100644 --- a/msa/js-executor/yarn.lock +++ b/msa/js-executor/yarn.lock @@ -1170,9 +1170,9 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== moment@^2.29.1: - version "2.30.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" - integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== + version "2.31.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.31.0.tgz#6e19184e8005a9dfc61c9351263d4d6ea2ace7aa" + integrity sha512-0acOTfMiWOheYS4eoWb80yYMb/JLvVv9SHbs2PehaDzfUG0Bw855SKyk0IKTnPGa5+U2bmi3W68l1+sGLX/pvw== ms@^2.1.1, ms@^2.1.3: version "2.1.3" @@ -1332,9 +1332,9 @@ progress@^2.0.3: integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== proxy-addr@^2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.8.tgz#624e760fd8ab06b1b8320c2f8506d4422cf8e932" + integrity sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ== dependencies: forwarded "0.2.0" ipaddr.js "1.9.1" diff --git a/msa/web-ui/package.json b/msa/web-ui/package.json index e0099bbdc5..f557b40769 100644 --- a/msa/web-ui/package.json +++ b/msa/web-ui/package.json @@ -13,7 +13,7 @@ "build": "tsc" }, "dependencies": { - "compression": "^1.8.1", + "compression": "^1.8.2", "config": "^3.3.12", "connect-history-api-fallback": "1.6.0", "express": "^5.1.0", diff --git a/msa/web-ui/yarn.lock b/msa/web-ui/yarn.lock index 3e96bc2e85..ca2d727bf8 100644 --- a/msa/web-ui/yarn.lock +++ b/msa/web-ui/yarn.lock @@ -511,14 +511,15 @@ compressible@~2.0.18: dependencies: mime-db ">= 1.43.0 < 2" -compression@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.8.1.tgz#4a45d909ac16509195a9a28bd91094889c180d79" - integrity sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w== +compression@^1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.8.2.tgz#781397127ae2da00c0c5f7c76bda5b2a9b32a49f" + integrity sha512-o8vI5RE5A6EVVOd9o41jKp41aJom+QTEO/Bx8MYNjexMo/Bv2WOjUfZr+aL0WnYSgymUy6zeguqLTsIhV0gMvQ== dependencies: bytes "3.1.2" compressible "~2.0.18" debug "2.6.9" + destroy "1.2.0" negotiator "~0.6.4" on-headers "~1.1.0" safe-buffer "5.2.1" @@ -604,6 +605,11 @@ depd@2.0.0, depd@^2.0.0: resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + detect-libc@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.4.tgz#f04715b8ba815e53b4d8109655b6508a6865a7e8" @@ -1127,9 +1133,9 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== moment@^2.29.1: - version "2.30.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" - integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== + version "2.31.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.31.0.tgz#6e19184e8005a9dfc61c9351263d4d6ea2ace7aa" + integrity sha512-0acOTfMiWOheYS4eoWb80yYMb/JLvVv9SHbs2PehaDzfUG0Bw855SKyk0IKTnPGa5+U2bmi3W68l1+sGLX/pvw== ms@2.0.0: version "2.0.0" @@ -1304,9 +1310,9 @@ progress@^2.0.3: integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== proxy-addr@^2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.8.tgz#624e760fd8ab06b1b8320c2f8506d4422cf8e932" + integrity sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ== dependencies: forwarded "0.2.0" ipaddr.js "1.9.1" diff --git a/ui-ngx/package.json b/ui-ngx/package.json index c410d5bed4..ab946678a2 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -67,7 +67,7 @@ "libphonenumber-js": "^1.12.35", "maplibre-gl": "5.2.0", "marked": "~16.4.2", - "moment": "^2.30.1", + "moment": "^2.31.0", "moment-timezone": "^0.6.0", "ngx-clipboard": "^16.0.0", "ngx-daterangepicker-material": "^6.0.4", diff --git a/ui-ngx/yarn.lock b/ui-ngx/yarn.lock index 9b6453cd01..a70a3e66fb 100644 --- a/ui-ngx/yarn.lock +++ b/ui-ngx/yarn.lock @@ -4861,13 +4861,14 @@ compressible@~2.0.18: mime-db ">= 1.43.0 < 2" compression@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.8.1.tgz#4a45d909ac16509195a9a28bd91094889c180d79" - integrity sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w== + version "1.8.2" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.8.2.tgz#781397127ae2da00c0c5f7c76bda5b2a9b32a49f" + integrity sha512-o8vI5RE5A6EVVOd9o41jKp41aJom+QTEO/Bx8MYNjexMo/Bv2WOjUfZr+aL0WnYSgymUy6zeguqLTsIhV0gMvQ== dependencies: bytes "3.1.2" compressible "~2.0.18" debug "2.6.9" + destroy "1.2.0" negotiator "~0.6.4" on-headers "~1.1.0" safe-buffer "5.2.1" @@ -7363,9 +7364,9 @@ js-tokens@^4.0.0: integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== js-yaml@^4.1.0, js-yaml@^4.3.0: - version "4.3.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.3.1.tgz#01216c001d67f48e2cd560d708c7af21090a3848" - integrity sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ== + version "4.3.2" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.3.2.tgz#8e44fb14a2643c59726bb15787b5f1512cb3d3fb" + integrity sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA== dependencies: argparse "^2.0.1" @@ -8104,10 +8105,10 @@ moment-timezone@^0.6.0: dependencies: moment "^2.29.4" -moment@^2.29.4, moment@^2.30.1: - version "2.30.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" - integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== +moment@^2.29.4, moment@^2.31.0: + version "2.31.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.31.0.tgz#6e19184e8005a9dfc61c9351263d4d6ea2ace7aa" + integrity sha512-0acOTfMiWOheYS4eoWb80yYMb/JLvVv9SHbs2PehaDzfUG0Bw855SKyk0IKTnPGa5+U2bmi3W68l1+sGLX/pvw== moo@^0.5.1: version "0.5.2" @@ -9110,9 +9111,9 @@ protocol-buffers-schema@^3.3.1: integrity sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw== proxy-addr@^2.0.7, proxy-addr@~2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.8.tgz#624e760fd8ab06b1b8320c2f8506d4422cf8e932" + integrity sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ== dependencies: forwarded "0.2.0" ipaddr.js "1.9.1" From a0684dc65f3ea7fce9fa807c6fa371659a232ce6 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 25 Sep 2026 10:45:58 +0300 Subject: [PATCH 35/39] Bump maplibre-gl from 5.2.0 to 6.11.2 to fix CVE-2026-85061 Fixes the XSS sanitizer bypass in DOM.sanitize() (GHSA-jrc7-96c5-q579, maplibre-gl <= 6.4.0). - v6 removed the internal map.transform: sync the GL map with Leaflet through the public jumpTo() and detect resizes from the container size - v6 is ESM-only and the worker must be registered via setWorkerUrl(): copy maplibre-gl-worker.mjs and its maplibre-gl-shared.mjs dependency to assets/maplibre-gl/ --- ui-ngx/angular.json | 10 + ui-ngx/package.json | 2 +- .../widget/lib/maps/leaflet/leaflet-tb.ts | 19 +- ui-ngx/yarn.lock | 262 +++++++----------- 4 files changed, 113 insertions(+), 180 deletions(-) diff --git a/ui-ngx/angular.json b/ui-ngx/angular.json index 08ffdd7b9a..49af337a74 100644 --- a/ui-ngx/angular.json +++ b/ui-ngx/angular.json @@ -77,6 +77,16 @@ "input": "node_modules/hugerte", "output": "/assets/hugerte/" }, + { + "glob": "maplibre-gl-worker.mjs", + "input": "node_modules/maplibre-gl/dist/", + "output": "/assets/maplibre-gl/" + }, + { + "glob": "maplibre-gl-shared.mjs", + "input": "node_modules/maplibre-gl/dist/", + "output": "/assets/maplibre-gl/" + }, { "glob": "marker-icon-2x.png", "input": "node_modules/leaflet/dist/images/", diff --git a/ui-ngx/package.json b/ui-ngx/package.json index ab946678a2..f72456f0a3 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -65,7 +65,7 @@ "leaflet.gridlayer.googlemutant": "0.15.0", "leaflet.markercluster": "1.5.3", "libphonenumber-js": "^1.12.35", - "maplibre-gl": "5.2.0", + "maplibre-gl": "6.11.2", "marked": "~16.4.2", "moment": "^2.31.0", "moment-timezone": "^0.6.0", diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet/leaflet-tb.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet/leaflet-tb.ts index 9ad91048d7..d092a0078f 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet/leaflet-tb.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet/leaflet-tb.ts @@ -3,7 +3,7 @@ import L, { TB } from 'leaflet'; import { guid, isDefinedAndNotNull, isNotEmptyStr } from '@core/utils'; import 'leaflet-providers'; -import { Map as MapLibreGLMap, LngLat as MapLibreGLLngLat } from 'maplibre-gl'; +import { Map as MapLibreGLMap, setWorkerUrl } from 'maplibre-gl'; import '@geoman-io/leaflet-geoman-free'; import 'leaflet.markercluster'; import { MatIconRegistry } from '@angular/material/icon'; @@ -1070,6 +1070,9 @@ const chinaProvider = (type: string, options?: L.TileLayerOptions): L.TB.TileLay return new ChinaProvider(type, options); } +// The worker is copied to assets by angular.json, bundlers cannot resolve it from import.meta.url +setWorkerUrl(new URL('assets/maplibre-gl/maplibre-gl-worker.mjs', document.baseURI).href); + class MapLibreGLLayer extends L.Layer implements TB.MapLibreGL.MapLibreGLLayer { options: TB.MapLibreGL.LeafletMapLibreGLMapOptions; @@ -1246,23 +1249,19 @@ class MapLibreGLLayer extends L.Layer implements TB.MapLibreGL.MapLibreGLLayer { this._transformGL(gl); - if (gl.transform.width !== size.x || gl.transform.height !== size.y) { + if (container.clientWidth !== size.x || container.clientHeight !== size.y) { container.style.width = size.x + 'px'; container.style.height = size.y + 'px'; gl.resize(); - } else { - gl._update(); } } private _transformGL(gl: MapLibreGLMap) { const center = this._map.getCenter(); - const tr = gl._getTransformForUpdate(); - if (!tr) { return; } - tr.setCenter(MapLibreGLLngLat.convert([center.lng, center.lat])); - tr.setZoom(this._map.getZoom() - 1); - gl.transform.apply(tr); - gl._fireMoveEvents(); + gl.jumpTo({ + center: [center.lng, center.lat], + zoom: this._map.getZoom() - 1 + }); } private _pinchZoom() { diff --git a/ui-ngx/yarn.lock b/ui-ngx/yarn.lock index a70a3e66fb..fdb5a6da01 100644 --- a/ui-ngx/yarn.lock +++ b/ui-ngx/yarn.lock @@ -2115,59 +2115,70 @@ resolved "https://registry.yarnpkg.com/@lmdb/lmdb-win32-x64/-/lmdb-win32-x64-3.4.2.tgz#99caf114bb74d39c9e1baca99b907353ad8bf461" integrity sha512-IY+r3bxKW6Q6sIPiMC0L533DEfRJSXibjSI3Ft/w9Q8KQBNqEIvUFXt+09wV8S5BRk0a8uSF19YWxuRwEfI90g== -"@mapbox/geojson-rewind@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@mapbox/geojson-rewind/-/geojson-rewind-0.5.2.tgz#591a5d71a9cd1da1a0bf3420b3bea31b0fc7946a" - integrity sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA== - dependencies: - get-stream "^6.0.1" - minimist "^1.2.6" - -"@mapbox/jsonlint-lines-primitives@^2.0.2", "@mapbox/jsonlint-lines-primitives@~2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz#ce56e539f83552b58d10d672ea4d6fc9adc7b234" - integrity sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ== +"@mapbox/jsonlint-lines-primitives@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.3.tgz#7d7b0b971fbaf6d60953272db4df03020d3fb004" + integrity sha512-0SElaV0uMxEnxzBhhX9WTuPyUeMsAN/SS0i16tjuba4/mio63MG9khjC1a0JAiPGXAwvwm4UfHJURCN7nyudQg== -"@mapbox/point-geometry@0.1.0", "@mapbox/point-geometry@^0.1.0", "@mapbox/point-geometry@~0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz#8a83f9335c7860effa2eeeca254332aa0aeed8f2" - integrity sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ== +"@mapbox/point-geometry@^1.1.0", "@mapbox/point-geometry@~1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-1.1.0.tgz#3328fb54b3a1273bc619bf0a6baad8de37181749" + integrity sha512-YGcBz1cg4ATXDCM/71L9xveh4dynfGmcLDqufR+nQQy3fKwsAZsWd/x4621/6uJaeB9mwOHE6hPeDgXz9uViUQ== -"@mapbox/tiny-sdf@^2.0.6": - version "2.0.7" - resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-2.0.7.tgz#0d67d65a43195003b282764f2297c619736bbc6e" - integrity sha512-25gQLQMcpivjOSA40g3gO6qgiFPDpWRoMfd+G/GoppPIeP6JDaMMkMrEJnMZhKyyS6iKwVt5YKu02vCUyJM3Ug== +"@mapbox/tiny-sdf@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-2.2.0.tgz#95dae0dc371b8c55c53d70f3e25d56823427f4c8" + integrity sha512-LVL4wgI9YAum5V+LNVQO6QgFBPw7/MIIY4XJPNsPDMrjEwcE+JfKk1LuIl8GnF197ejVdC9QdPaxrx5gfgdGXg== -"@mapbox/unitbezier@^0.0.1": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@mapbox/unitbezier/-/unitbezier-0.0.1.tgz#d32deb66c7177e9e9dfc3bbd697083e2e657ff01" - integrity sha512-nMkuDXFv60aBr9soUG5q+GvZYL+2KZHVvsqFCzqnkGEf46U2fvmytHaEVc1/YZbiLn8X+eR3QzX1+dwDO1lxlw== +"@mapbox/unitbezier@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mapbox/unitbezier/-/unitbezier-1.0.0.tgz#54319aff6c467bb1b909e04895c08cdb966bfbff" + integrity sha512-fqd515fjBmANKGGsQ286E2Wvj/XvDFpGzwJxq4CI6jMQue6Oy04uCKp+JWKF00xRTmk6cEu1jPJ9p3xqH8YWqQ== -"@mapbox/vector-tile@^1.3.1": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz#d3a74c90402d06e89ec66de49ec817ff53409666" - integrity sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw== +"@mapbox/vector-tile@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@mapbox/vector-tile/-/vector-tile-3.0.0.tgz#71a75acb5ee20c20adca5c4e1ffb5ef95a56e351" + integrity sha512-Qf10S1uIHMk20ri/IVBnpS+esUEkVaR5Hftmz88jTInrpmWgPGJfPe3LVjjlE77trLx8tH6qjTG7uWH9hIq/0Q== dependencies: - "@mapbox/point-geometry" "~0.1.0" + "@mapbox/point-geometry" "~1.1.0" + "@types/geojson" "^7946.0.16" + pbf "^5.0.0" -"@mapbox/whoots-js@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe" - integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q== +"@maplibre/geojson-vt@^6.1.1": + version "6.1.1" + resolved "https://registry.yarnpkg.com/@maplibre/geojson-vt/-/geojson-vt-6.1.1.tgz#25a032435b4ce2236ea0ba911aff5fb6d5454fc1" + integrity sha512-FVMOcmSP/yqol45t7StApEyTL5/vmqBCuFhH9n+fFuINenhaX+YgHHIt1yJ86S8kln3uJLcMvmEU2cfn6E2eCQ== + dependencies: + kdbush "^4.1.0" -"@maplibre/maplibre-gl-style-spec@^23.1.0": - version "23.3.0" - resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.3.0.tgz#b69ab48cb3abead4e49213396c8f83492638b97c" - integrity sha512-IGJtuBbaGzOUgODdBRg66p8stnwj9iDXkgbYKoYcNiiQmaez5WVRfXm4b03MCDwmZyX93csbfHFWEJJYHnn5oA== +"@maplibre/maplibre-gl-style-spec@^26.4.4": + version "26.4.4" + resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-26.4.4.tgz#e103d50f9eed8a44f1fde1c4970c5d2a47b19b78" + integrity sha512-hG4RZR4PBd/+6A3ODdZ3AnQRF106ZQk1y3bhwDg8bH/A4Oz2tnRUJVVWs9BZa6gXZ1d3UKe89C+Mm+olGBELvA== dependencies: - "@mapbox/jsonlint-lines-primitives" "~2.0.2" - "@mapbox/unitbezier" "^0.0.1" + "@mapbox/jsonlint-lines-primitives" "^2.0.3" + "@mapbox/unitbezier" "^1.0.0" json-stringify-pretty-compact "^4.0.0" minimist "^1.2.8" quickselect "^3.0.0" - rw "^1.3.3" tinyqueue "^3.0.0" +"@maplibre/mlt@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@maplibre/mlt/-/mlt-1.3.0.tgz#3a9467d12a0b6edfcdba429dd3a260ca48f11129" + integrity sha512-7M2O7ABM80Oi8XPkfkrjKB8mOBIxGoVgkA52Mu4RMWoBvvMdagQ522+WxVYujZsMpqIr3BpzrTbXrm4k8lCzCQ== + dependencies: + "@mapbox/point-geometry" "^1.1.0" + +"@maplibre/vt-pbf@^4.3.2": + version "4.3.2" + resolved "https://registry.yarnpkg.com/@maplibre/vt-pbf/-/vt-pbf-4.3.2.tgz#cfcdbdadaf88b4cb8645e43c8eead77cd6546030" + integrity sha512-j6p0AdjvAR19Z3XaCysle7A4ZSo08tYOzxD0Y9NQylwPAkwJJeYub5b2eVucdeDh7erhv69DahoLOevDRERRUw== + dependencies: + "@mapbox/point-geometry" "^1.1.0" + "@types/geojson" "^7946.0.16" + pbf "^5.1.0" + "@mat-datetimepicker/core@~16.0.1": version "16.0.1" resolved "https://registry.yarnpkg.com/@mat-datetimepicker/core/-/core-16.0.1.tgz#f2b19b6ed85f83a83f93be866af1a9564ac0d978" @@ -3503,13 +3514,6 @@ resolved "https://registry.yarnpkg.com/@types/flowjs/-/flowjs-2.13.14.tgz#62cdd8d5d8e0222e505e4a140e73cd385c0a496c" integrity sha512-OlZFH9hbOq5B+GeBjcM3UvvSailseRT+sKoi9jyFFczvvS1n1LTiTKJysDSLVWnUvGD+tsn7kxb6eC2uaJD+Zw== -"@types/geojson-vt@3.2.5": - version "3.2.5" - resolved "https://registry.yarnpkg.com/@types/geojson-vt/-/geojson-vt-3.2.5.tgz#b6c356874991d9ab4207533476dfbcdb21e38408" - integrity sha512-qDO7wqtprzlpe8FfQ//ClPV9xiuoh2nkIgiouIptON9w5jvD/fA4szvP9GBlDVdJ5dldAl0kX/sy3URbWwLx0g== - dependencies: - "@types/geojson" "*" - "@types/geojson@*", "@types/geojson@^7946.0.10", "@types/geojson@^7946.0.16": version "7946.0.16" resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a" @@ -3594,20 +3598,6 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.23.tgz#c1bb06db218acc8fc232da0447473fc2fb9d9841" integrity sha512-RDvF6wTulMPjrNdCoYRC8gNR880JNGT8uB+REUpC2Ns4pRqQJhGz90wh7rgdXDPpCczF3VGktDuFGVnz8zP7HA== -"@types/mapbox__point-geometry@*", "@types/mapbox__point-geometry@^0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@types/mapbox__point-geometry/-/mapbox__point-geometry-0.1.4.tgz#0ef017b75eedce02ff6243b4189210e2e6d5e56d" - integrity sha512-mUWlSxAmYLfwnRBmgYV86tgYmMIICX4kza8YnE/eIlywGe2XoOxlpVnXWwir92xRLjwyarqwpu2EJKD2pk0IUA== - -"@types/mapbox__vector-tile@^1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@types/mapbox__vector-tile/-/mapbox__vector-tile-1.3.4.tgz#ad757441ef1d34628d9e098afd9c91423c1f8734" - integrity sha512-bpd8dRn9pr6xKvuEBQup8pwQfD4VUyqO/2deGjfpe6AwC8YRlyEipvefyRJUSiCJTZuCb8Pl1ciVV5ekqJ96Bg== - dependencies: - "@types/geojson" "*" - "@types/mapbox__point-geometry" "*" - "@types/pbf" "*" - "@types/mime@^1": version "1.3.5" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" @@ -3625,11 +3615,6 @@ dependencies: undici-types "~6.21.0" -"@types/pbf@*", "@types/pbf@^3.0.5": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@types/pbf/-/pbf-3.0.5.tgz#a9495a58d8c75be4ffe9a0bd749a307715c07404" - integrity sha512-j3pOPiEcWZ34R6a6mN07mUkM4o4Lwf6hPNt8eilOeZhTFbxFXmKhvXl9Y28jotFPaI1bpPDJsbCprUoNke6OrA== - "@types/qs@*": version "6.9.16" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.16.tgz#52bba125a07c0482d26747d5d4947a64daf8f794" @@ -3686,13 +3671,6 @@ dependencies: "@types/node" "*" -"@types/supercluster@^7.1.3": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@types/supercluster/-/supercluster-7.1.3.tgz#1a1bc2401b09174d9c9e44124931ec7874a72b27" - integrity sha512-Z0pOY34GDFl3Q6hUFYf3HkTwKEE02e7QgtJppBt+beEAxnyOpJua+voGFvxINBHa06GwLFFym7gRPY2SiKIfIA== - dependencies: - "@types/geojson" "*" - "@types/systemjs@6.15.3": version "6.15.3" resolved "https://registry.yarnpkg.com/@types/systemjs/-/systemjs-6.15.3.tgz#d758dceafee62d2ed4aad7d07342b145d623e260" @@ -4437,6 +4415,13 @@ beasties@0.3.5: postcss "^8.4.49" postcss-media-query-parser "^0.2.3" +bidi-js@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/bidi-js/-/bidi-js-1.1.0.tgz#c92efafe3fce3b9fdd30ba67bdddf0dd4d424af7" + integrity sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg== + dependencies: + require-from-string "^2.0.2" + big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -5606,10 +5591,10 @@ dunder-proto@^1.0.0, dunder-proto@^1.0.1: es-errors "^1.3.0" gopd "^1.2.0" -earcut@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.0.2.tgz#d478a29aaf99acf418151493048aa197d0512248" - integrity sha512-X7hshQbLyMJ/3RPhyObLARM2sNxxmRALLKx1+NVFFnQ9gKzmCrxm9+uLIAdBcvc8FNLpctqlQ2V6AE92Ol9UDQ== +earcut@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.2.3.tgz#74aec19555a7e28773429826729d2e4bfeb19022" + integrity sha512-vnS4AVwp1KHAF13i1vp1/2D5evWy3k5u/iW/B81QVsUZtV8cv2tU0b2VNFlqvh4kYwrFMDdjPCfAmfyJW9y14Q== eastasianwidth@^0.2.0: version "0.2.0" @@ -6483,11 +6468,6 @@ gensync@^1.0.0-beta.2: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== -geojson-vt@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/geojson-vt/-/geojson-vt-4.0.2.tgz#1162f6c7d61a0ba305b1030621e6e111f847828a" - integrity sha512-AV9ROqlNqoZEIJGfm1ncNjEXfkz2hdFlZf0qkVfmkwdKa8vj7H16YUOT81rJw1rdFhyEDlN2Tds91p/glzbl5A== - get-caller-file@^2.0.1, get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" @@ -6522,11 +6502,6 @@ get-proto@^1.0.1: dunder-proto "^1.0.1" es-object-atoms "^1.0.0" -get-stream@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - get-symbol-description@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.1.0.tgz#7bdd54e0befe8ffc9f3b4e203220d9f1e881b6ee" @@ -6536,7 +6511,7 @@ get-symbol-description@^1.1.0: es-errors "^1.3.0" get-intrinsic "^1.2.6" -gl-matrix@^3.4.3: +gl-matrix@^3.4.4: version "3.4.4" resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.4.4.tgz#7789ee4982f62c7a7af447ee488f3bd6b0c77003" integrity sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ== @@ -6586,15 +6561,6 @@ glob@^13.0.0: minipass "^7.1.2" path-scurry "^2.0.0" -global-prefix@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-4.0.0.tgz#e9cc79aab9be1d03287e156a3f912dd0895463ed" - integrity sha512-w0Uf9Y9/nyHinEk5vMJKRie+wa4kR5hmDbEhGGds/kG1PwGLLHKRoNMeJOyCQjjBkANlnScqgzcFwGHgmgLkVA== - dependencies: - ini "^4.1.3" - kind-of "^6.0.3" - which "^4.0.0" - globals@^14.0.0: version "14.0.0" resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" @@ -6853,11 +6819,6 @@ icss-utils@^5.0.0, icss-utils@^5.1.0: resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== -ieee754@^1.1.12: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - ignore-walk@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-8.0.0.tgz#380c173badc3a18c57ff33440753f0052f572b14" @@ -6918,11 +6879,6 @@ ini@^1.3.4: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -ini@^4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/ini/-/ini-4.1.3.tgz#4c359675a6071a46985eb39b14e4a2c0ec98a795" - integrity sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg== - ini@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/ini/-/ini-6.0.0.tgz#efc7642b276f6a37d22fdf56ef50889d7146bf30" @@ -7511,10 +7467,10 @@ katex@^0.16.0, katex@^0.16.25: dependencies: commander "^8.3.0" -kdbush@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/kdbush/-/kdbush-4.0.2.tgz#2f7b7246328b4657dd122b6c7f025fbc2c868e39" - integrity sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA== +kdbush@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/kdbush/-/kdbush-4.1.0.tgz#d504bc0447a59be4fb75533a5c25e316b3ed8859" + integrity sha512-e9vurzrXJQrFX6ckpHP3bvj5l+9CnYzkxDNnNQ1h2QTqdWsUAJgXiKdGNcOa1EY85dU8KbQ+z/FdQdB7P+9yfQ== keyv@^4.5.4: version "4.5.4" @@ -7528,7 +7484,7 @@ khroma@^2.1.0: resolved "https://registry.yarnpkg.com/khroma/-/khroma-2.1.0.tgz#45f2ce94ce231a437cf5b63c2e886e6eb42bbbb1" integrity sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw== -kind-of@^6.0.2, kind-of@^6.0.3: +kind-of@^6.0.2: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -7825,37 +7781,29 @@ make-plural@^7.0.0: resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.4.0.tgz#fa6990dd550dea4de6b20163f74e5ed83d8a8d6d" integrity sha512-4/gC9KVNTV6pvYg2gFeQYTW3mWaoJt7WZE5vrp1KnQDgW92JtYZnzmZT81oj/dUTqAIu0ufI2x3dkgu3bB1tYg== -maplibre-gl@5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-5.2.0.tgz#e3cdb66c82232cffbe149b032776484722caee4e" - integrity sha512-9zZKD0M80qtDsqBet+EDuAhoCeA/cnAuZAA0p3hcGKGbyjM/SH+R6wQvnBEgvJz9UhDynnkoKdUwhI+fUkHoXQ== - dependencies: - "@mapbox/geojson-rewind" "^0.5.2" - "@mapbox/jsonlint-lines-primitives" "^2.0.2" - "@mapbox/point-geometry" "^0.1.0" - "@mapbox/tiny-sdf" "^2.0.6" - "@mapbox/unitbezier" "^0.0.1" - "@mapbox/vector-tile" "^1.3.1" - "@mapbox/whoots-js" "^3.1.0" - "@maplibre/maplibre-gl-style-spec" "^23.1.0" +maplibre-gl@6.11.2: + version "6.11.2" + resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-6.11.2.tgz#25f1266666c16f6b935cabccba554c238a3cf394" + integrity sha512-Xh06pxoipjX/Ad1sUPGhiNh9go9naCNGZZ1IJm3sIeqK1kYGuMaMDSTIGDQ2igOLfVyukJU7kvEOA089VO7Z7g== + dependencies: + "@mapbox/point-geometry" "^1.1.0" + "@mapbox/tiny-sdf" "^2.2.0" + "@mapbox/unitbezier" "^1.0.0" + "@mapbox/vector-tile" "^3.0.0" + "@maplibre/geojson-vt" "^6.1.1" + "@maplibre/maplibre-gl-style-spec" "^26.4.4" + "@maplibre/mlt" "^1.3.0" + "@maplibre/vt-pbf" "^4.3.2" "@types/geojson" "^7946.0.16" - "@types/geojson-vt" "3.2.5" - "@types/mapbox__point-geometry" "^0.1.4" - "@types/mapbox__vector-tile" "^1.3.4" - "@types/pbf" "^3.0.5" - "@types/supercluster" "^7.1.3" - earcut "^3.0.1" - geojson-vt "^4.0.2" - gl-matrix "^3.4.3" - global-prefix "^4.0.0" - kdbush "^4.0.2" + bidi-js "^1.1.0" + earcut "^3.2.3" + gl-matrix "^3.4.4" + kdbush "^4.1.0" murmurhash-js "^1.0.0" - pbf "^3.3.0" - potpack "^2.0.0" + pbf "^5.1.2" + potpack "^2.1.0" quickselect "^3.0.0" - supercluster "^8.0.1" tinyqueue "^3.0.0" - vt-pbf "^3.1.3" marked@^16.3.0, marked@~16.4.2: version "16.4.2" @@ -8845,12 +8793,11 @@ pathe@^2.0.1, pathe@^2.0.3: resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.3.tgz#3ecbec55421685b70a9da872b2cff3e1cbed1716" integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== -pbf@^3.2.1, pbf@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/pbf/-/pbf-3.3.0.tgz#1790f3d99118333cc7f498de816028a346ef367f" - integrity sha512-XDF38WCH3z5OV/OVa8GKUNtLAyneuzbCisx7QUCF8Q6Nutx0WnJrQe5O+kOtBlLfRNUws98Y58Lblp+NJG5T4Q== +pbf@^5.0.0, pbf@^5.1.0, pbf@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/pbf/-/pbf-5.1.2.tgz#07c427819eda32f02f1ec9741558f61444f2e1c0" + integrity sha512-mnvGdvOrIvJOBGUEdGkrVXjN8E/VkIJCkf2eS1DH2yv82ORUlLttmDt0rWY38yYZmVwciZwBUvHM20qxBZf40w== dependencies: - ieee754 "^1.1.12" resolve-protobuf-schema "^2.1.0" photoswipe@^5.4.4: @@ -9053,7 +9000,7 @@ postinstall-prepare@^2.0.0: resolved "https://registry.yarnpkg.com/postinstall-prepare/-/postinstall-prepare-2.0.0.tgz#2a6867c1a13a05502aa115d0495efbbd778769cb" integrity sha512-lLFwEKdnGLAaRAm8OpXP6HwrXRW+b8Hh9vRhVHZKmCdobd+D21YM38BCDsi3zrePLSe8Tt0H/mbYkh7/ySQQMg== -potpack@^2.0.0: +potpack@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/potpack/-/potpack-2.1.0.tgz#fe548e2f9061e9937f17191c1ab6dd98ca30e02f" integrity sha512-pcaShQc1Shq0y+E7GqJqvZj8DTthWV1KeHGdi0Z6IAin2Oi3JnLCOfwnCo84qc+HAp52wT9nK9H7FAJp5a44GQ== @@ -9495,7 +9442,7 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -rw@1, rw@^1.3.3: +rw@1: version "1.3.3" resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" integrity sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ== @@ -10172,13 +10119,6 @@ sucrase@^3.35.0: tinyglobby "^0.2.11" ts-interface-checker "^0.1.9" -supercluster@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-8.0.1.tgz#9946ba123538e9e9ab15de472531f604e7372df5" - integrity sha512-IiOea5kJ9iqzD2t7QJq/cREyLHTtSmUT6gQsweojg9WH2sYJqZK9SswTu6jrscO6D1G5v5vYZ9ru/eq85lXeZQ== - dependencies: - kdbush "^4.0.2" - supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -10787,15 +10727,6 @@ vscode-uri@~3.1.0: resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.1.0.tgz#dd09ec5a66a38b5c3fffc774015713496d14e09c" integrity sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ== -vt-pbf@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/vt-pbf/-/vt-pbf-3.1.3.tgz#68fd150756465e2edae1cc5c048e063916dcfaac" - integrity sha512-2LzDFzt0mZKZ9IpVF2r69G9bXaP2Q2sArJCmcCgvfTdCCZzSyz4aCLoQyUilu37Ll56tCblIZrXFIjNUpGIlmA== - dependencies: - "@mapbox/point-geometry" "0.1.0" - "@mapbox/vector-tile" "^1.3.1" - pbf "^3.2.1" - watchpack@2.4.4: version "2.4.4" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.4.tgz#473bda72f0850453da6425081ea46fc0d7602947" @@ -11025,13 +10956,6 @@ which@^2.0.1: dependencies: isexe "^2.0.0" -which@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/which/-/which-4.0.0.tgz#cd60b5e74503a3fbcfbf6cd6b4138a8bae644c1a" - integrity sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg== - dependencies: - isexe "^3.1.1" - which@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/which/-/which-6.0.0.tgz#a3a721a14cdd9b991a722e493c177eeff82ff32a" From b8628b0c7562a47b45c38b87119ead9fb4a1aa77 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Mon, 28 Sep 2026 12:11:31 +0300 Subject: [PATCH 36/39] Bump io.netty from 4.1.137.Final to 4.1.138.Final to fix CVE-2026-93488, CVE-2026-93491, and 4 others --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index db90bce5f5..304e1874e2 100755 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ entries below once TB migrates its tests off the deprecated @SpyBean/@MockBean to @MockitoSpyBean/@MockitoBean. --> 3.5.13 3.18.0 - 4.1.137.Final + 4.1.138.Final 10.1.59 5.4.3 1.5.38 From b4f24ac998f6a9231585aadbe66da256e13741b8 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Mon, 28 Sep 2026 12:11:31 +0300 Subject: [PATCH 37/39] Bump jackson-bom from 2.21.6 to 2.21.7 to fix CVE-2026-89425 and CVE-2026-91777 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 304e1874e2..d407c6abdd 100755 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 10.1.59 5.4.3 1.5.38 - 2.21.6 + 2.21.7 42.7.12 5.34.0 5.6.4 From b3930b66921aeca13a9bedaf42a1e9244001dc14 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Mon, 28 Sep 2026 12:11:31 +0300 Subject: [PATCH 38/39] Bump zookeeper from 3.9.5 to 3.9.6 to fix CVE-2026-59969 and CVE-2026-84439 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d407c6abdd..31053c56e9 100755 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ 2.0.0-M15 2.0.1 5.6.0 - 3.9.5 + 3.9.6 3.25.5 1.76.0 1.2.10 From c24219461ae6cd050d7e4b12558d2ac65481da65 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Mon, 28 Sep 2026 12:11:31 +0300 Subject: [PATCH 39/39] Bump freemarker from 2.3.34 to 2.3.35 to fix CVE-2026-84939 --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 31053c56e9..76920fadeb 100755 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ 5.34.0 5.6.4 1.5.7-14 + 2.3.35 2.4.0-b180830.0359 0.12.5 0.10 @@ -1122,6 +1123,13 @@ ${zstd-jni.version} + + + org.freemarker + freemarker + ${freemarker.version} + + org.springframework.boot spring-boot-dependencies