Skip to content

[PM-38272] fix: handle null or empty permissions in OrganizationUserResponseModel - #8207

Open
JaredScar wants to merge 2 commits into
mainfrom
ac/pm-38272-members-page-stop-sending-empty-permissions-data-for-non-custom-users
Open

[PM-38272] fix: handle null or empty permissions in OrganizationUserResponseModel#8207
JaredScar wants to merge 2 commits into
mainfrom
ac/pm-38272-members-page-stop-sending-empty-permissions-data-for-non-custom-users

Conversation

@JaredScar

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38272

📔 Objective

Stops sending back empty permissions model for non-custom users

Updated the OrganizationUserResponseModel to set Permissions to null if the input is null or whitespace, ensuring proper handling of permissions data. Added JsonIgnore attribute to exclude null Permissions from JSON serialization.
@JaredScar
JaredScar requested a review from a team as a code owner August 13, 2026 17:38
@JaredScar JaredScar added the ai-review Request a Claude code review label Aug 13, 2026
@JaredScar JaredScar added the t:tech-debt Change Type - Tech debt label Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR stops emitting an all-false Permissions object for organization members with no stored permissions: both OrganizationUserResponseModel constructors now use the documented GetPermissions() accessor (which returns null for null/whitespace JSON) and the property is annotated with [JsonIgnore(WhenWritingNull)] so it is omitted from the response. The change is confined to the admin console response model; runtime authorization paths (OrganizationUserValidationService, UserDecryptionOptionsBuilder, ProfileOrganizationResponseModel) are untouched. Custom-type members always have permissions persisted at invite time (OrganizationService.cs:587, CreateOrganizationUserExtensions.cs:29), so the omission only affects non-Custom members, matching the stated objective.

Code Review Details

No blocking findings. The previously raised duplication of the null guard was addressed by switching to GetPermissions().

Note: test/Api.Test/AdminConsole/Models/Response/OrganizationUserResponseModelTests.cs already constructs org users with Permissions = null but does not assert result.Permissions is null, so the new behavior remains unasserted.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.22%. Comparing base (5358a2f) to head (939c1a2).

Additional details and impacted files
@@            Coverage Diff            @@
##           main    #8207       +/-   ##
=========================================
+ Coverage      0   63.22%   +63.22%     
=========================================
  Files         0     2381     +2381     
  Lines         0   103757   +103757     
  Branches      0     9385     +9385     
=========================================
+ Hits          0    65604    +65604     
- Misses        0    35924    +35924     
- Partials      0     2229     +2229     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Replaced the previous permissions loading logic with a direct call to GetPermissions() method, enhancing code clarity and maintainability. Removed unnecessary null or whitespace checks for permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant