From 3498785184698a687fd7a7a7c7d24709b32c8324 Mon Sep 17 00:00:00 2001 From: Adam Simpson Date: Thu, 2 Mar 2023 11:27:27 -0500 Subject: [PATCH] AzureMonitor: Fix query variable migration (#63991) * AzureMonitor: Fix query variable migration Somehow the query object becomes "unwriteable" post 9.4. To workaround this I clone the query object before doing any migrations which removes the immutability and allows the migrations to function as they did. Fixes #63943 * refactor deepClone out to keep object the same --- .../azuremonitor/utils/migrateQuery.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/public/app/plugins/datasource/azuremonitor/utils/migrateQuery.ts b/public/app/plugins/datasource/azuremonitor/utils/migrateQuery.ts index c1e9ad03edc..784ba2e4fc2 100644 --- a/public/app/plugins/datasource/azuremonitor/utils/migrateQuery.ts +++ b/public/app/plugins/datasource/azuremonitor/utils/migrateQuery.ts @@ -33,7 +33,15 @@ export default function migrateQuery(query: AzureMonitorQuery): AzureMonitorQuer } if (workingQuery.azureLogAnalytics?.resource) { - workingQuery = migrateLogsResource(workingQuery); + workingQuery = { + ...workingQuery, + azureLogAnalytics: { + ...workingQuery.azureLogAnalytics, + resources: [workingQuery.azureLogAnalytics.resource], + }, + }; + + delete workingQuery.azureLogAnalytics?.resource; } return workingQuery; @@ -179,15 +187,3 @@ function migrateResourceGroupAndName(query: AzureMonitorQuery): AzureMonitorQuer return workingQuery; } - -function migrateLogsResource(query: AzureMonitorQuery): AzureMonitorQuery { - let workingQuery = query; - - if (workingQuery.azureLogAnalytics && workingQuery.azureLogAnalytics.resource) { - workingQuery.azureLogAnalytics.resources = [workingQuery.azureLogAnalytics.resource]; - - delete workingQuery.azureLogAnalytics.resource; - } - - return workingQuery; -}