microsoftgraph / microsoftgraph/msgraph-beta-sdk-java

User::getProfile retrieves null when it shouldn't

Open
#1,256 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
Java
Stars
32
Forks
14
Avg merge
1d 3h
Merged PRs (30d)
6

Description

Describe the bug

I'm trying to get all users in a group and after that getting the users profile.
While this won't work:

  1. getting Users as transitiveMembers of a group
    UserCollectionResponse userResult = graphClient.groups() .byGroupId(groupId) .transitiveMembers() .graphUser() .get();
  2. iterate over all users
    userResult.getValue().forEach(this::getProfile);
  3. call User::getProfile but it returns always null even when profile is existing and permissions are granted.
    private void getProfile(User user) { Profile profile = user.getProfile(); }

It will work when you do this instead of user.getProfile() in step 3:
private void getProfile(User user) { Profile profile = graphClient.users().byUserId(user.getId()).profile().get(); }
This returns the profile for me.

Expected behavior

when calling User::getProfile i expect to get the profile back instead of null.

How to reproduce
  1. getting Users as transitiveMembers of a group
    UserCollectionResponse userResult = graphClient.groups() .byGroupId(groupId) .transitiveMembers() .graphUser() .get();
  2. iterate over all users
    userResult.getValue().forEach(this::getProfile);
  3. call User::getProfile but it returns always null even when profile is existing and permissions are granted.
    private void getProfile(User user) { Profile profile = user.getProfile(); }
SDK Version

6.47.0

Latest version known to work for scenario above?

No response

Known Workarounds

Use:
graphClient.users().byUserId(user.getId()).profile().get();
instead of User::getProfile

Debug output
Configuration

No response

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 by reproducing the transitiveMembers() flow and inspect User::getProfile() for users returned by that chain. Compare it with graphClient.users().byUserId(user.getId()).profile().get(); done means the direct User profile access returns the existing profile in the reported scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.