Skip to content

Commit aa954bd

Browse files
Fix the null check when converting to PSRoledefinition (#24759)
* Fix the null check when converting to PSRoledefinition * Update src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs Co-authored-by: Beisi Zhou <[email protected]> * address review comment --------- Co-authored-by: Beisi Zhou <[email protected]>
1 parent 408d5ff commit aa954bd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added null check to the permissions object in the ToPSRoleDefinition method to return if the whole permissions object array is null.
2223

2324
## Version 6.16.2
2425
* Introduced secrets detection feature to safeguard sensitive data.

src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public static PSRoleDefinition ToPSRoleDefinition(this RoleDefinition role)
5858
AssignableScopes = role.AssignableScopes.ToList(),
5959
Description = role.Description,
6060
IsCustom = role.RoleType == CustomRole ? true : false,
61-
Condition = role.Permissions[0]?.Condition,
62-
ConditionVersion = role.Permissions[0]?.ConditionVersion
61+
Condition = role?.Permissions?[0]?.Condition,
62+
ConditionVersion = role?.Permissions?[0]?.ConditionVersion
6363
};
6464
}
6565

0 commit comments

Comments
 (0)