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

Deleting role assignment generating invalid GET request #1208

Closed
1 task done
JakeStanger opened this issue Jun 15, 2023 · 3 comments
Closed
1 task done

Deleting role assignment generating invalid GET request #1208

JakeStanger opened this issue Jun 15, 2023 · 3 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@JakeStanger
Copy link

JakeStanger commented Jun 15, 2023

Category

  • Bug

Describe the bug

There looks to be a few issues with this one. From a quick look at the code, it looks to be a different cause to #1206.

When attempting to delete a role assignment, a GET request is sent to attempt to get the assignment by ID, this is pointing to the wrong URL, which #1207 should resolve.

It also looks like the ID is not getting correctly substituted (and not caught at runtime like it is in #1206), causing a request to be sent without the ID, resulting in a 400 response:

The expression "Web/RoleAssignments/GetByPrincipal({PrincipalId})" is not valid.

Steps to reproduce

  1. Add one or more role assignments to a site for custom SP groups.
  2. Run below code snippet
  3. Experience error
var roleAssignments = await context.Web.RoleAssignments.ToListAsync();
foreach (var roleAssignment in roleAssignments)
{
    Console.WriteLine(roleAssignment.PrincipalId); // just for the sake of reading the principal id
    await roleAssignment.DeleteAsync();
}

Expected behavior

A valid DELETE request is sent, or valid request to the removeroleassignment endpoint, and the role assignment is correctly removed.

Environment details (development & target environment)

  • SDK version: 1.9.72-nightly
  • OS: Windows 11
  • SDK used in: Azure Functions
  • Framework: .NET 6
  • Tooling: Jetbrains Rider
@JakeStanger JakeStanger changed the title Getting role assignment by principal ID generating invalid request Deleting role assignment generating invalid GET request Jun 15, 2023
@jansenbe jansenbe self-assigned this Jun 15, 2023
@jansenbe jansenbe added bug Something isn't working area: model 📐 Related to the core SDK models labels Jun 15, 2023
@jansenbe
Copy link
Contributor

@JakeStanger : thanks for raising this and for the PR to fix the issue. I've just merged the PR, will be part of the next nightly, hence I'll close this issue now.

@JakeStanger
Copy link
Author

@jansenbe thanks for merging the PR but the issue is still not fixed, as the ID is still not being substituted.

The new nightly is resulting in a 400 with the following message:

The expression "Web/RoleAssignments/GetByPrincipalId({PrincipalId})" is not valid.

@jansenbe jansenbe reopened this Jun 16, 2023
@jansenbe
Copy link
Contributor

@JakeStanger : now it's fixed, I've added test cases to cover the RoleAssignment deletions when used on Web, List and ListItem.

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 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants