Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoleAssignments will not be returned for all lists #625

Closed
1 task done
pxmonti opened this issue Nov 14, 2021 · 3 comments
Closed
1 task done

RoleAssignments will not be returned for all lists #625

pxmonti opened this issue Nov 14, 2021 · 3 comments
Assignees
Labels
area: model 📐 Related to the core SDK models question Further information is requested

Comments

@pxmonti
Copy link

pxmonti commented Nov 14, 2021

Category

  • Bug

Description

Calling LoadAsync for all lists of a web, will not return role assigments for any of the lists.

Steps to reproduce

await ctx.Web.LoadAsync(
w => w.Lists.QueryProperties(
l => l.Fields.QueryProperties(
p => p.InternalName,
p => p.FieldTypeKind,
p => p.TypeAsString,
p => p.Title
),
l => l.Title,
l => l.HasUniqueRoleAssignments,
l => l.RoleAssignments.QueryProperties(
ra => ra.PrincipalId,
ra => ra.RoleDefinitions.QueryProperties(
rd => rd.Id,
rd => rd.Name
)
)
));

Expected behavior

After calling this method, for any of the returned lists/libraries the RoleAssignment property contains no records:

foreach(var reqList in ctx.Web.Lists.AsRequested())
{
foreach(var ra in reqList.RoleAssignments.AsRequested())
{
// we will never get here since RoleAssigments contains zero records
Console.WriteLine($"{ra.PrincipalId}");
}
}

Incredibly enough, this instead WILL return the role assigments (simply not querying the "Fields" property)

await ctx.Web.LoadAsync(
w => w.Lists.QueryProperties(
l => l.Title,
l => l.HasUniqueRoleAssignments,
l => l.RoleAssignments.QueryProperties(
ra => ra.PrincipalId,
ra => ra.RoleDefinitions.QueryProperties(
rd => rd.Id,
rd => rd.Name
)
)
));

Why requesting the roleassigments together with other properties (in this case the "Fields" property) wouldn't return items, while it would if requested alone?

NOTE: this does NOT happen if the list is requested through GetByTitle

The following WILL work:

var list = ctx.Web.Lists.GetByTitle("Documents",
l => l.Title,
l => l.Id,
l => l.HasUniqueRoleAssignments,
l => l.RoleAssignments.QueryProperties(
ra => ra.PrincipalId,
ra => ra.RoleDefinitions.QueryProperties(
rd => rd.Id
)
),
l => l.Fields.QueryProperties(
p => p.InternalName,
p => p.FieldTypeKind,
p => p.TypeAsString,
p => p.Title
));

SDK Version:
1.4.34-nightly

@jansenbe jansenbe self-assigned this Nov 14, 2021
@jansenbe jansenbe added area: model 📐 Related to the core SDK models question Further information is requested labels Nov 14, 2021
@jansenbe
Copy link
Contributor

Thanks @pxmonti , I've managed to reproduce the error. Something goes wrong in the code that translates this to a REST query, the second top level query properties is "appended" onto the first expand... I'll work on a fix.

@pxmonti
Copy link
Author

pxmonti commented Nov 14, 2021

Thanks @jansenbe , I'll wait for a fix. If this can help, I've noticed that also other top-level properties would "break" the query, e.g. "RootFolder".

jansenbe added a commit that referenced this issue Nov 14, 2021
…em has child `QueryProperties` generated a wrong query #625
@jansenbe
Copy link
Contributor

@pxmonti : just committed a fix. When you try with tomorrow's version things will work. Thanks for providing the feedback. Closing the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants