{Role} Fix: az role assignment list-changelogs fails with KeyError#14461
Merged
{Role} Fix: az role assignment list-changelogs fails with KeyError#14461
az role assignment list-changelogs fails with KeyError#14461Conversation
Collaborator
|
RBAC |
az role assignment list-changelogs fails with KeyErroraz role assignment list-changelogs fails with KeyError
arrownj
reviewed
Sep 9, 2020
jsntcy
reviewed
Sep 9, 2020
| entry['roleName'] = role_defs[payload['roleDefinitionId']][0] | ||
| # Look up the resource `name`, like b24988ac-6180-42a0-ab88-20f7382dd24c | ||
| role_resource_name = payload['roleDefinitionId'].split('/')[-1] | ||
| entry['roleDefinitionId'] = role_resource_name |
Member
There was a problem hiding this comment.
Who will use entry['roleDefinitionId'] later? Now it is like b24988ac-6180-42a0-ab88-20f7382dd24c, is it expected?
Member
Author
There was a problem hiding this comment.
This key has the same value as the original behavior:
d.id.split('/')[-1]
I didn't change the value.
jsntcy
approved these changes
Sep 9, 2020
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.
Symptom
az role assignment list-changelogsfails withKeyError:Cause
This is because when the role assignment is created, it uses a child role definition
which inherits from the actual role definition
This can be verified by calling Role Definitions - Get:
but the result from Role Definitions - List only has the actual role definition, not the child one, so the key lookup fails to retrieve the child one:
azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Line 334 in 4c28536
This PR changes the lookup logic to only use the resource name (last GUID part) as role definition key, so that the role definition can be resolved and shown correctly:
Command Usage
Luckily, according to client telemetry, in the last 7 days, there are only 29 invocations of this command from 8 subscriptions.
Remarks
This issue is discovered when fixing the live tests for
rolecommand module (#14317).