microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Incorrect error when querying AdministrativeUnit membership

Open
#3,156 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:waiting-for-triage type:bug
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug

My application needs to verify that a created user has joined an administrative unit with dynamic membership rules. Since querying the member directly hits another bug I'm making a query on the membership collection instead with filter

var userFilter = $"id eq '{id}'";

So here's the query

var items = await graphServiceClient.Directory.AdministrativeUnits[unitId].Members.GetAsync(o => 
{
    o.QueryParameters.Filter = filter;
}).ConfigureAwait(false);

I'm making that request immediately after creating the user, so the dynamic membership hasn't been applied yet. So, I'm expecting an empty result. Instead I'm getting an exception:

Request_ResourceNotFound - Resource '510f02dc-ce75-49dc-a964-7259341d973d' does not exist or one of its queried reference-property objects are not present

There's but one problem... the Resource mentioned that's my administrative unit, not the memberId I'm looking for. Thus, the error is wrong. It should say 'Resource 'id'' does not exist or one of its queried reference-property objects are not present'

If I wait for a minute and run the same code again, it returns success and returns the member - so I know what I'm querying is correct.

Expected behavior

The error should say that the Resource 'id' (with the ID I'm querying) is not present, not the Id of the Admin Unit (which most definitely IS present)

How to reproduce

Create an admin unit with dynamic membership, and create a rule on the UPN. Then create a user with a UPN matching the rule you created.
Immediately after creating the new user, run the query as described above on the AdminUnit.. you'll get the error.

SDK Version

6.2.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

Win 11 Pro x64
.NET SDK 10.0.302

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AdminUnit members request shown in the issue and reproduce it immediately after creating a user whose UPN matches a dynamic membership rule. Inspect how this request reports a not-found error when membership has not propagated, comparing the administrative-unit ID with the queried member ID. Done means the error identifies the missing member resource accurately rather than the existing administrative unit.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.