Skip to content

Unhandled Exception in IAuthRolesAdminService.UpdateRoleToPermissionsAsync() when a RoleType change is detected #124

@ccnicholls99

Description

@ccnicholls99

If you pass in a set of Permissions that would force a change of RoleType, you get a System.NullReferenceException: Object reference not set to an instance of an object.

The exception occurs in AuthPermissions.AdminCode.Services.Internal.ChangeRoleTypeChecks.CheckRoleTypeChangeAsync, Line 102, where the method UserErrorMessageAsync is called. The var formattableString is expecting an instance but is getting null instead.

private async Task<FormattableString> UserErrorMessageAsync(string roleName, bool filterOutNonTenantUsers) {
    ...logic omitted...
    return (num > 0) ? ((FormattableString)$"{num} users are linked to it.") : null;
}

Installed NuGet AuthPermissions.AspNetCore, Version: 9.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions