From e265c09af5bf9edaa5e0e192eca71407290ff2aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 08:43:06 +0000 Subject: [PATCH 1/2] Initial plan From 61abe4498f3a92353a2683d1195d240395a5fc3e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 08:47:14 +0000 Subject: [PATCH 2/2] Fix ARM resource ID keys being camelCased in userAssignedIdentities When az containerapp create --yaml is used with userAssignedIdentities, the keys (ARM resource IDs) were incorrectly camelCased by _convert_object_from_snake_to_camel_case, corrupting underscores in resource group names (e.g. _NAME_PARTS -> NameParts). Fix: skip camelCase conversion for keys that start with '/' (ARM resource IDs). Add unit test to verify the fix. Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/16735815-60d3-490a-8345-5bb464d4ba68 Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../command_modules/containerapp/_utils.py | 2 +- .../tests/latest/test_containerapp_utils.py | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py b/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py index 4d03c999853..1af89cebe85 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py @@ -942,7 +942,7 @@ def _convert_object_from_snake_to_camel_case(o): if isinstance(o, list): return [_convert_object_from_snake_to_camel_case(i) if isinstance(i, (dict, list)) else i for i in o] return { - _to_camel_case(a): _convert_object_from_snake_to_camel_case(b) if isinstance(b, (dict, list)) else b for a, b in o.items() + (_to_camel_case(a) if not a.startswith('/') else a): _convert_object_from_snake_to_camel_case(b) if isinstance(b, (dict, list)) else b for a, b in o.items() } diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py index 16641e3e569..f74ab2c5647 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py @@ -5,7 +5,7 @@ import unittest import os -from azure.cli.command_modules.containerapp._utils import clean_null_values, load_cert_file +from azure.cli.command_modules.containerapp._utils import clean_null_values, load_cert_file, _convert_object_from_snake_to_camel_case from azure.cli.core.azclierror import CLIInternalError TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) @@ -211,6 +211,29 @@ def test_clean_empty_values(self): self.assertEqual(expect_result_for_new, result_new) self.assertEqual(expect_result_for_old, result_old) + def test_convert_object_from_snake_to_camel_case_preserves_arm_resource_id_keys(self): + # ARM resource IDs used as dictionary keys (e.g. in userAssignedIdentities) + # must not be modified by camelCase conversion. Underscores in resource group + # names would otherwise be incorrectly collapsed into camelCase segments. + arm_resource_id = ( + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + "/resourcegroups/NAME-PARTS-DIVIDED-BY-DASHES-RG_NAME_PARTS_DIVIDED_BY_UNDERSCORES" + "/providers/Microsoft.ManagedIdentity/userAssignedIdentities/SOME-Managed-Identity" + ) + input_obj = { + "identity": { + "user_assigned_identities": { + arm_resource_id: {} + }, + "type": "UserAssigned" + } + } + result = _convert_object_from_snake_to_camel_case(input_obj) + self.assertIn("identity", result) + self.assertIn("userAssignedIdentities", result["identity"]) + self.assertIn(arm_resource_id, result["identity"]["userAssignedIdentities"], + "ARM resource ID key must not be camelCased") + def test_load_cert_file(self): pfx_file = os.path.join(TEST_DIR, 'data', 'cert.pfx') testpassword = 'test12'