Skip to content

[PM-37595] Use New OrganizationUserStatusType Columns#7693

Open
sven-bitwarden wants to merge 2 commits into
mainfrom
ac/pm-37595/use-new-status-columns
Open

[PM-37595] Use New OrganizationUserStatusType Columns#7693
sven-bitwarden wants to merge 2 commits into
mainfrom
ac/pm-37595/use-new-status-columns

Conversation

@sven-bitwarden
Copy link
Copy Markdown
Contributor

@sven-bitwarden sven-bitwarden commented May 22, 2026

🎟️ Tracking

PM-37595

📔 Objective

This PR implements phase 2 of separating revoked from OrganizationUserStatusType.

A prior PR added the column to support the work. This PR now begins lightly using the new column.
When a user is revoked, we will copy the status they were being revoked from into the column. In essence, this acts like a "prior status" placeholder.
If/when the user is subsequently restored, and the user has a value present for the new status type, we will restore them from the placeholder. If no value is present (they were revoked before we started tracking this dual-column system), we fallback to existing logic.

@sven-bitwarden sven-bitwarden requested review from a team as code owners May 22, 2026 04:39
@sven-bitwarden sven-bitwarden requested a review from jrmccannon May 22, 2026 04:39
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.86%. Comparing base (d903096) to head (810eafa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7693   +/-   ##
=======================================
  Coverage   64.86%   64.86%           
=======================================
  Files        2140     2140           
  Lines       94629    94635    +6     
  Branches     8445     8446    +1     
=======================================
+ Hits        61378    61383    +5     
- Misses      31155    31156    +1     
  Partials     2096     2096           

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

@sven-bitwarden sven-bitwarden requested a review from eliykat May 22, 2026 05:40
@sven-bitwarden sven-bitwarden added needs-qa ai-review-vnext Request a Claude code review using the vNext workflow labels May 22, 2026
Copy link
Copy Markdown
Member

@eliykat eliykat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really tidy and nicely done. Just one thought below.

INNER JOIN
@OrganizationUserIds OUI ON OUI.[Id] = OU.[Id]
WHERE
OU.[Status] != -1 -- Skip already-revoked rows so existing StatusNew / RevocationReason are preserved
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice potential catch

Comment on lines +121 to +125
// OrganizationUserStatusTypeNew has no Revoked variant, so any populated value is valid.
if (StatusNew.HasValue)
{
return (OrganizationUserStatusType)(short)StatusNew.Value;
}
Copy link
Copy Markdown
Member

@eliykat eliykat May 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While your comment is true, and all things going well we should never end up with an invalid value, I am leaning towards being more defensive about it.

The cast does not validate that the enum is in a valid range: https://dotnetfiddle.net/KeF7Ke. So if we do end up with a bad value, it propagates through the system.

We could have an explicit conversion method instead:

public static class OrganizationUserStatusTypeNewExtensions 
  {                                                 
      public static OrganizationUserStatusType ToOrganizationUserStatusType(this OrganizationUserStatusTypeNew status) 
          => status switch       
          {  
              OrganizationUserStatusTypeNew.Invited => OrganizationUserStatusType.Invited,
              OrganizationUserStatusTypeNew.Accepted => OrganizationUserStatusType.Accepted, 
              OrganizationUserStatusTypeNew.Confirmed => OrganizationUserStatusType.Confirmed, 
              _ => // TODO: how to handle this? Throw, or return null for the caller to handle?
          };      
  }  

Open for discussion.

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

Labels

ai-review-vnext Request a Claude code review using the vNext workflow needs-qa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants