Repository navigation
[Core] Preserve identities when single instance is removed - #34383
Merged
Naga Nandyala (naga-nandyala) merged 1 commit intoNov 9, 2026
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
3 tasks done
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Contributor
|
Hi Nate Prewitt (@nateprewitt), |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the selective identity-removal fix.
No open issues 🎉
What changed in this PR
Fixes shared AAZ identity-removal logic so removing one specified user-assigned identity preserves unselected identities. The issue was discovered during Storage management API work.
Changes:
- Uses a nonempty-list check to distinguish selective removal from removing all user-assigned identities.
- Adds regression tests for removing one assigned or unassigned identity, both with and without a system-assigned identity.
| File | Description |
|---|---|
src/azure-cli-core/azure/cli/core/tests/test_aaz_identity.py |
Adds identity-preservation regression tests. |
src/azure-cli-core/azure/cli/core/aaz/_field_value.py |
Corrects selective removal for a single identity. |
Review effort: Balanced
Member
Author
|
mansoor sarfraz (@msarfraz) Aditya Pujara (@a0x1ab), can we get eyes on this for current milestone since it's not a new PR? |
Nate Prewitt (nateprewitt)
added a commit
to nateprewitt/azure-cli
that referenced
this pull request
Nov 9, 2026
Naga Nandyala (naga-nandyala)
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation — ️✔️ All clear
Related command
N/A
Description
This was an issue found working on #34305. There is an assumption built into identity removal that selected identity removal will always be for more than one instance. If exactly one instance is removed from a set, the entire identities collection is dropped by the
elsestatement. This change instead checks for truthiness in the list (we could also check for len but this would typically be considered more pythonic).There's no context on why the
>1check was originally added in the originating PR, but it seems like it was a confusion ofuser_assignedandidentities. i.e. if there is more than one identityif len(identities) > 1then try to remove. That has other issues though where it assumes a removal with only one identity constitutesidentities = {}which is also wrong.Testing Guide
From the repository root in a configured CLI development environment:
New tests verify that removing one specified user-assigned identity preserves unselected identities, and requesting removal of an unassigned identity leaves existing identities unchanged. Both cases cover resources with and without a system-assigned identity.
History Notes
[Core] Fix removal of a single specified user-assigned identity incorrectly removing all user-assigned identities.
This checklist is used to make sure that common guidelines for a pull request are followed.