Skip to content

[PM-39805] fix: Expose SM migration-grace service accounts on subscription response - #7901

Merged
amorask-bitwarden merged 1 commit into
mainfrom
billing/pm-39805-sm-additional-machine-accounts-grace
Jul 1, 2026
Merged

amorask-bitwarden merged 1 commit into
mainfrom
billing/pm-39805-sm-additional-machine-accounts-grace

Conversation

@amorask-bitwarden

Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

After a Teams Starter 2023 → Teams (Monthly) migration, the Secrets Manager subscription response priced the permanent migration-grace service accounts as billable. The web vault's "Additional machine accounts" field showed 55 (30 grace + 25 paid) at $55/month, while the billing summary and Stripe correctly billed 25 @ $25/month — two conflicting machine-account costs for the same subscription.

The grace allotment (e.g. 30 = source SM baseline 50 − target baseline 20) is written to Stripe subscription metadata as migration_grace_service_accounts at migration, but was never surfaced on the subscription response, so the client could not exclude it.

This PR exposes that count on the subscription/organization response via SubscriptionInfo.ServiceAccountGrace (read through SubscriptionExtensions.GetMigrationGraceServiceAccounts), letting the client subtract the free, permanent grace from the billable additional-machine-accounts figure. The field then reports 25 @ $1 = $25, matching the billing summary and Stripe.

Unit tests added in StripePaymentServiceTests (Core.Test) and OrganizationsControllerTests (Api.Test).

…ption response

Post-migration organizations overstated billable additional machine accounts:
the subscription GET response carried no grace value, so the client computed
additional = SmServiceAccounts - BaseServiceAccount without subtracting the
permanently-free migration-grace allotment.

Surface the grace count (already written to Stripe subscription metadata during
migration and consumed on the write path) as a flat SmServiceAccountsGrace field
on the organization subscription response, mapped from metadata via the existing
GetMigrationGraceServiceAccounts extension. Null on self-host and no-gateway
paths; left intact under hideSensitiveData since it is a non-sensitive count.
@amorask-bitwarden amorask-bitwarden added ai-review Request a Claude code review t:bugfix Change Type - Bugfix labels Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed this bugfix that surfaces the Secrets Manager migration-grace service-account count on the organization subscription response so clients can exclude permanently-free grace accounts from the billable additional-machine-accounts figure. The change reads the count from Stripe subscription metadata via SubscriptionExtensions.GetMigrationGraceServiceAccounts, maps it onto BillingSubscription.ServiceAccountGrace, and exposes it as the nullable SmServiceAccountsGrace on the response model. The added null-guard on subscription.Metadata correctly prevents an NRE for non-migrated subscriptions, and the grace count is intentionally preserved through the hideSensitiveData branch as a non-sensitive value. Unit tests cover the migration-grace, no-grace, self-hosted, no-gateway, and sensitive-data-hiding paths.

No security, correctness, breaking-change, or performance concerns identified.

@sonarqubecloud

Copy link
Copy Markdown

@amorask-bitwarden
amorask-bitwarden marked this pull request as ready for review June 30, 2026 20:12
@amorask-bitwarden
amorask-bitwarden requested review from a team as code owners June 30, 2026 20:12
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 61.37%. Comparing base (7ae670a) to head (30fa1c2).

Files with missing lines Patch % Lines
...esponse/Organizations/OrganizationResponseModel.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7901      +/-   ##
==========================================
+ Coverage   61.28%   61.37%   +0.08%     
==========================================
  Files        2226     2226              
  Lines       98296    98301       +5     
  Branches     8884     8886       +2     
==========================================
+ Hits        60242    60330      +88     
+ Misses      35934    35841      -93     
- Partials     2120     2130      +10     

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

@sbrown-livefront sbrown-livefront left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Great fix

@amorask-bitwarden
amorask-bitwarden merged commit a96e6cd into main Jul 1, 2026
57 of 63 checks passed
@amorask-bitwarden
amorask-bitwarden deleted the billing/pm-39805-sm-additional-machine-accounts-grace branch July 1, 2026 19:11
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:bugfix Change Type - Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants