You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CheckIfUserHasPermissionAsync for IListItem (coming from IFile) throws "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
It's happening in
ListItem.cs file line -> 1679 - > Method "BuildGetUserEffectivePermissionsApiCall"
Seems that the Parent.Parent is not a list, it's a Web object. var parentList = Parent.Parent as List;
Then it fails during string formatting because parentList is null
Steps to reproduce
var file = await clientContext.Web.GetFileByServerRelativeUrlAsync(relativeUrl,
f => f.ListItemAllFields.QueryProperties(p => p.ParentList), f => f.Parent);
var item = file.ListItemAllFields;
//BUG in PnP.Core - Workaround - Uncomment if you want that it works
//item.Parent.Parent = item.ParentList;
return await item.CheckIfUserHasPermissionsAsync(spUser.UserPrincipalName, permission);
Expected behavior
To not do the workaround
var file = await clientContext.Web.GetFileByServerRelativeUrlAsync(relativeUrl,
f => f.ListItemAllFields.QueryProperties(p => p.ParentList), f => f.Parent);
var item = file.ListItemAllFields;
return await item.CheckIfUserHasPermissionsAsync(spUser.UserPrincipalName, permission);
Category
Describe the bug
CheckIfUserHasPermissionAsync for IListItem (coming from IFile) throws "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
It's happening in
ListItem.cs file line -> 1679 - > Method "BuildGetUserEffectivePermissionsApiCall"
Seems that the Parent.Parent is not a list, it's a Web object.
var parentList = Parent.Parent as List;
Then it fails during string formatting because parentList is null
Steps to reproduce
Expected behavior
To not do the workaround
Environment details (development & target environment)
The text was updated successfully, but these errors were encountered: