Skip to content

UserType discrepancy between enum value and Graph API response #1736

Description

Describe the bug

The following Microsoft Graph API endpoint:
https://graph.microsoft.com/v1.0/users/{{azureUserId}}?$select=userType

returns

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(userType)/$entity",
  "userType": "Member"
}

However, the Microsoft\Graph\Generated\Models\UserType generated enum of the SDK contains
public const MEMBER = "member";

If an integration intends to proactively remove non-member type users from the system using code such as:

if ($azureUser->getUserType() !== UserType::MEMBER) {
    $azureUser->delete();
}

this risks removing all Azure users from the system, because an Azure user of user type member would satisfy this condition as well ('member' !== 'Member' is true).

Note: This discrepancy between the API response and the generated SDK has triggered an incident in a production environment of a software product, because the unit tests use the UserType value from the SDK.

Expected behavior

The UserType enum/const should have values capitalized.
Any other enum/consts contained in the SDK should be reviewed for correctness to be in-line with the actual API responses.

How to reproduce

See issue description. There's discrepancy between the API response and the SDK enum/const value.

SDK Version

"microsoft/microsoft-graph": "^2.3",

Latest version known to work for scenario above?

None.

Known Workarounds

Not using UserType, hardcoding sentence-cased value.

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions