Skip to content

Conversation

@g1n93r
Copy link
Contributor

@g1n93r g1n93r commented Dec 3, 2025

Changes

This PR fixes a bug in the OrganizationMember class where the Roles property was incorrectly defined as non-nullable. The Roles property is optional and may be null when organization members are retrieved without explicitly requesting the roles field via the OrganizationGetAllMembersRequest.

Classes and methods changed:

  • OrganizationMember.Roles property type changed from IList<Role> to IList<Role>? (nullable)
  • Added XML documentation to OrganizationMember.Roles clarifying that:
    • The property is optional and may be null
    • It will only be present when OrganizationGetAllMembersRequest.Fields includes "roles" and OrganizationGetAllMembersRequest.IncludeFields is true

Why this is important:
When retrieving organization members without explicitly requesting roles (which is the default behavior), the Auth0 API does not include the roles field in the response. Previously, the non-nullable type could cause deserialization issues or force consumers to handle null values despite the type not indicating it could be null. This change makes the API contract more accurate and prevents potential runtime errors.

Usage:

// When roles are NOT requested (default behavior)
var members = await client.Organizations.GetAllMembersAsync(orgId, new PaginationInfo());
// members[0].Roles will be null

// When roles ARE explicitly requested
var membersWithRoles = await client.Organizations.GetAllMembersAsync(
    orgId, 
    new OrganizationGetAllMembersRequest { Fields = "roles", IncludeFields = true }, 
    new PaginationInfo());
// membersWithRoles[0].Roles will contain the roles list

References

This change aligns the SDK with the Auth0 Management API behavior where the roles field is only included in organization member responses when explicitly requested via the fields query parameter.

Testing

This change can be tested by:

  1. Existing integration tests: The existing test Test_organization_member_roles_crud_sequence in OrganizationTests.cs (line 359) already tests the scenario where roles are explicitly requested and should continue to pass.

  2. Manual testing:

    • Retrieve organization members without requesting roles and verify Roles is null
    • Retrieve organization members with Fields = "roles" and IncludeFields = true and verify Roles is populated
  3. Regression testing: All existing integration tests should continue to pass, particularly:

    • Test_organization_members_crud_sequence - tests member retrieval without roles
    • Test_organization_member_roles_crud_sequence - tests member retrieval with roles
  • This change adds unit test coverage
  • This change adds integration test coverage (existing tests cover this scenario)
  • This change has been tested on the latest version of the platform/language

Checklist

@g1n93r g1n93r requested a review from a team as a code owner December 3, 2025 15:56
@g1n93r g1n93r changed the title fix(ManagementApi): make OrganizationMember.Roles nullable Make OrganizationMember.Roles nullable Dec 3, 2025
@kailash-b
Copy link
Contributor

Hi @g1n93r 👋

Thanks for this PR!

We have reviewed the changes and tested them locally; everything looks great, and the tests are passing too.

However, there is just one final step before we can merge. We require all commits to be verified (signed) as per our contribution guidelines.

Could you please sign your commits? GitHub has a guide here.

Do let us know if you run into any issues!

The Roles property is optional and may be null when the organization member
is retrieved without explicitly requesting the roles field. This change
updates the property type to be nullable and adds XML documentation
clarifying that the property will only be present when
OrganizationGetAllMembersRequest.Fields includes "roles" and
IncludeFields is true.
The Roles property is optional and may be null when the organization member
is retrieved without explicitly requesting the roles field. This change
updates the property type to be nullable and adds XML documentation
clarifying that the property will only be present when
OrganizationGetAllMembersRequest.Fields includes "roles" and
IncludeFields is true.
@g1n93r
Copy link
Contributor Author

g1n93r commented Dec 4, 2025

Hi @g1n93r 👋

Thanks for this PR!

We have reviewed the changes and tested them locally; everything looks great, and the tests are passing too.

However, there is just one final step before we can merge. We require all commits to be verified (signed) as per our contribution guidelines.

Could you please sign your commits? GitHub has a guide here.

Do let us know if you run into any issues!

Here you go :) Let me know if you need anything else

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 8.96%. Comparing base (0f8cc0b) to head (f81cfc2).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...ementApi/Models/Organization/OrganizationMember.cs 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0f8cc0b) and HEAD (f81cfc2). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (0f8cc0b) HEAD (f81cfc2)
authIntTests 1 0
mgmtIntTests 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #895       +/-   ##
==========================================
- Coverage   79.20%   8.96%   -70.25%     
==========================================
  Files         457     372       -85     
  Lines        5915    4484     -1431     
  Branches      277     176      -101     
==========================================
- Hits         4685     402     -4283     
- Misses       1136    4066     +2930     
+ Partials       94      16       -78     
Flag Coverage Δ
authIntTests ?
mgmtIntTests ?
unittests 8.96% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kailash-b kailash-b merged commit 4050302 into auth0:master Dec 5, 2025
4 of 7 checks passed
@kailash-b kailash-b mentioned this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants