Skip to content

[PM-33951] feat(admin-console): Add bulk confirmation and pending auto-confirmation#7661

Merged
JaredScar merged 12 commits into
mainfrom
ac/pm-33919-db-changes
May 27, 2026
Merged

[PM-33951] feat(admin-console): Add bulk confirmation and pending auto-confirmation#7661
JaredScar merged 12 commits into
mainfrom
ac/pm-33919-db-changes

Conversation

@JaredScar
Copy link
Copy Markdown
Contributor

@JaredScar JaredScar commented May 18, 2026

🎟️ Tracking

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

📔 Objective

This PR contains the database changes needed for #7527, split to their own PR to manage PR size.

…ion methods for organization users

- Implemented ConfirmManyOrganizationUsersAsync to confirm multiple users in a single operation.
- Added GetManyPendingAutoConfirmAsync to retrieve users pending automatic confirmation.
- Created stored procedures for bulk confirmation and fetching pending users.
- Updated relevant repository interfaces and implementations across Dapper and Entity Framework.
@JaredScar JaredScar requested review from a team as code owners May 18, 2026 16:05
@JaredScar JaredScar added the ai-review Request a Claude code review label May 18, 2026
@JaredScar JaredScar requested a review from r-tome May 18, 2026 16:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR adds the database layer for bulk organization user confirmation: a new OrganizationUser_UpdateManyStatusKey stored procedure (with matching Dapper and EF implementations), a new OrganizationUser_ReadByPendingAutoConfirm query for finding eligible auto-confirmable members, and integration test coverage for both. The SQL is well-formed (parameterized via OPENJSON, idempotent via WHERE [Status] = 1, atomic OUTPUT INTO to track confirmed IDs), and the EF mirror correctly filters to Status = Accepted before mutating rows. Source-of-truth and migration scripts are now in sync on VARCHAR(MAX) for the [Key] column, and the previously-flagged issues from earlier review rounds (migration date collision, SP rename, type-code mismatch, missing RevisionDate assertion, unused SP cleanup) are all resolved.

Code Review Details

No new findings. All previously raised concerns have been addressed in the resolved threads:

  • Source-of-truth OrganizationUser_UpdateManyStatusKey.sql and migration 2026-05-27_00_AddOrganizationUserUpdateStatusKey.sql both use VARCHAR(MAX) for [Key], matching the OrganizationUser table.
  • OrganizationUser_ReadByPendingAutoConfirm correctly filters [Type] = 2 (User) per the resolved type-code discussion.
  • Integration tests assert RevisionDate is updated and verify that non-Accepted users are not modified.
  • Migration files use the current date (2026-05-27) with no sequence collisions.
  • The superseded OrganizationUser_ReadByOrganizationIdStatus.sql was removed.

@JaredScar JaredScar changed the title [PM-33919] feat(admin-console): Add bulk confirmation and pending auto-confirmation [PM-33951] feat(admin-console): Add bulk confirmation and pending auto-confirmation May 18, 2026
Comment thread util/Migrator/DbScripts/2026-05-14_01_AddOrganizationUserConfirmByIds.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_ReadByOrganizationIdStatus.sql Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 52.17391% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.96%. Comparing base (d903096) to head (e72c414).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...Console/Repositories/OrganizationUserRepository.cs 29.41% 12 Missing ⚠️
...Console/Repositories/OrganizationUserRepository.cs 65.51% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7661      +/-   ##
==========================================
+ Coverage   64.86%   64.96%   +0.10%     
==========================================
  Files        2140     2143       +3     
  Lines       94629    94914     +285     
  Branches     8445     8492      +47     
==========================================
+ Hits        61378    61662     +284     
+ Misses      31155    31143      -12     
- Partials     2096     2109      +13     

☔ 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.

Copy link
Copy Markdown
Contributor

@r-tome r-tome left a comment

Choose a reason for hiding this comment

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

Claude pointed out a few things to fix. Let me know when to review this again

@mkincaid-bw
Copy link
Copy Markdown
Contributor

There are similar database changes in PR 7527, as well as this one. Do both PR's need a review from dbops or only this one?

@JaredScar
Copy link
Copy Markdown
Contributor Author

JaredScar commented May 19, 2026

There are similar database changes in PR 7527, as well as this one. Do both PR's need a review from dbops or only this one?

Valid question! @mkincaid-bw -- Sorry for the confusion. @eliykat suggested we split up that PR into smaller PRs like this one that we merge first, then that original PR will be smaller and easier to review since that big chunk of code are broken into pieces. Theoretically speaking, this should be the only one DB ops needs to worry about 😄

…ationUsersAsync to IReadOnlyCollection

- Updated the ConfirmManyOrganizationUsersAsync method signature in the IOrganizationUserRepository and its implementations to use IReadOnlyCollection instead of IEnumerable for better performance and clarity.
- Adjusted related repository methods in both Dapper and Entity Framework implementations to reflect this change.
- Added unit tests to ensure the new implementation behaves as expected, including scenarios for mixed batches and idempotency.
@JaredScar JaredScar requested a review from r-tome May 19, 2026 19:50
@eliykat eliykat self-requested a review May 21, 2026 04:53
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.

Thanks @JaredScar for splitting this to a separate PR - I cannot tell you how much easier it is to review smaller PRs.

Aside from my comments below, please check the CI runs:

  • db integration test is failing - potentially faulty prod or test logic
  • db validation is failing - this ensures that the migration scripts match the src/Sql files
  • validate new migration naming and order - this is failing because later migrations have overtaken you and you need to bump the dates on your script

More info available in each of the runs, or hit me up on Slack if you have questions.

EDIT: please also add more info to your PR description, e.g.

This PR contains the database changes needed for #7527, split to their own PR to manage PR size.

The PR link is particularly useful to understand what's going on.

Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_ReadByOrganizationIdStatus.sql Outdated
JaredScar and others added 3 commits May 21, 2026 11:48
…dingAutoConfirm methods

- Introduced ConfirmManyOrganizationUsersTests to validate the confirmation of multiple organization users, ensuring only accepted users are confirmed and idempotency is maintained.
- Added GetManyPendingAutoConfirmTests to verify retrieval of pending auto-confirm users, ensuring only eligible users are returned based on specific criteria.
- Removed duplicate test implementations from OrganizationUserRepositoryTests to maintain clarity and organization in the test suite.
@JaredScar JaredScar requested a review from eliykat May 21, 2026 16:03
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_ConfirmByIds.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_ReadByPendingAutoConfirm.sql Outdated
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.

My changes have been addressed, I can approve once @mkincaid-bw is happy and CI checks are passing.

r-tome
r-tome previously requested changes May 22, 2026
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_ConfirmByIds.sql Outdated
JaredScar and others added 2 commits May 22, 2026 12:12
…e related repository method

- Added OrganizationUser_UpdateStatusKey stored procedure to handle updating the status and key of organization users based on a JSON input.
- Updated OrganizationUserRepository to call the new stored procedure instead of the previous confirmation procedure.
- Modified OrganizationUser_ReadByPendingAutoConfirm stored procedure to filter users by a new type value.
- Enhanced integration tests to verify the correct behavior of the updated confirmation logic, ensuring revision dates are accurately tracked.
@JaredScar JaredScar requested review from eliykat and r-tome May 22, 2026 16:42
@JaredScar JaredScar requested a review from mkincaid-bw May 22, 2026 16:42
Copy link
Copy Markdown
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

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

Couple more minor changes.

Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateStatusKey.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateStatusKey.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateStatusKey.sql Outdated
@JaredScar JaredScar requested a review from mkincaid-bw May 22, 2026 20:53
…anyStatusKey

- Renamed the stored procedure to OrganizationUser_UpdateManyStatusKey to better reflect its functionality of updating multiple organization users' statuses.
- Updated the OrganizationUserRepository to call the new stored procedure.
- Adjusted the migration script to create or alter the procedure accordingly.
Copy link
Copy Markdown
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

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

Sorry, I should have flagged the data type changes in the migration script as well. Also have some really minor, petty spacing nit picks 😄

Comment thread util/Migrator/DbScripts/2026-05-22_00_AddOrganizationUserUpdateStatusKey.sql Outdated
Comment thread util/Migrator/DbScripts/2026-05-22_00_AddOrganizationUserUpdateStatusKey.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateManyStatusKey.sql Outdated
Comment thread src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateManyStatusKey.sql Outdated
@eliykat eliykat removed their request for review May 25, 2026 23:12
@eliykat
Copy link
Copy Markdown
Member

eliykat commented May 25, 2026

Please re-request review when feedback is addressed and CI is passing, thanks. If you need any help just let me know.

… migration script

- Changed the data type of the Key column from NVARCHAR(MAX) to VARCHAR(MAX) in the UsersToUpdate table and the corresponding JSON parsing logic to improve compatibility and performance.
@JaredScar JaredScar requested review from eliykat and mkincaid-bw May 26, 2026 20:18
mkincaid-bw
mkincaid-bw previously approved these changes May 26, 2026
Copy link
Copy Markdown
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

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

LGTM

@eliykat eliykat removed the request for review from r-tome May 26, 2026 22:37
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.

Migration dates need bumping again 😢

@JaredScar JaredScar requested review from eliykat and r-tome May 27, 2026 17:02
JaredScar added 2 commits May 27, 2026 13:03
- Created OrganizationUser_UpdateManyStatusKey to update multiple organization users' statuses based on a JSON input, including handling revision dates and tracking updated IDs for idempotency.
- Added OrganizationUser_ReadByPendingAutoConfirm to retrieve organization users pending auto-confirmation based on organization ID and specific status and type filters.
@sonarqubecloud
Copy link
Copy Markdown

@JaredScar JaredScar dismissed stale reviews from r-tome and eliykat May 27, 2026 22:05

Resolved

@JaredScar JaredScar merged commit eacafae into main May 27, 2026
49 of 50 checks passed
@JaredScar JaredScar deleted the ac/pm-33919-db-changes branch May 27, 2026 22:06
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants