Skip to content

[Role] RoleAssignmentProperties.principalType should not have default value User #21664

Open
@jiasli

Description

@jiasli

During Azure CLI's migration to azure-mgmt-authorization Track 2 SDK (Azure/azure-cli#23372), this change is spotted.

In the previous API 2020-04-01-preview, RoleAssignmentProperties.principalType has no default value:

"principalType": {
"type": "string",
"description": "The principal type of the assigned principal ID.",
"enum": [
"User",
"Group",
"ServicePrincipal",
"Unknown",
"DirectoryRoleTemplate",
"ForeignGroup",
"Application",
"MSI",
"DirectoryObjectOrGroup",
"Everyone"
],
"x-ms-enum": {
"name": "PrincipalType",
"modelAsString": true
}
},

In the latest API 2022-04-01, it has a default value of User:

"principalType": {
"type": "string",
"description": "The principal type of the assigned principal ID.",
"enum": [
"User",
"Group",
"ServicePrincipal",
"ForeignGroup",
"Device"
],
"default": "User",
"x-ms-enum": {
"name": "PrincipalType",
"modelAsString": true
}
},
"description": {
"type": "string",
"description": "Description of role assignment"
},

This breaks Azure CLI as we assume principalType is by default None:

https://github.com/Azure/azure-cli/blob/7232ac23b23c8b5b26a6cfd514600207bb79ebce/src/azure-cli/azure/cli/command_modules/role/_multi_api_adaptor.py#L50-L51

        if assignee_principal_type:
            parameters.principal_type = assignee_principal_type

There should be no assumption that principalType is a User.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions