Skip to content

Conversation

@kdenney
Copy link
Contributor

@kdenney kdenney commented Jan 6, 2026

🎟️ Tracking

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

📔 Objective

Fixes an oversight so that the reconcile storage job also updates the database MaxStorageGb after stripe reconciliation.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@kdenney kdenney marked this pull request as ready for review January 6, 2026 18:39
@kdenney kdenney requested review from a team as code owners January 6, 2026 18:39
@kdenney kdenney added the ai-review Request a Claude code review label Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 97.41379% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.09%. Comparing base (2026ca1) to head (e641db9).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/Billing/Jobs/ReconcileAdditionalStorageJob.cs 97.41% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6803      +/-   ##
==========================================
+ Coverage   54.96%   55.09%   +0.12%     
==========================================
  Files        1930     1934       +4     
  Lines       85507    85690     +183     
  Branches     7654     7668      +14     
==========================================
+ Hits        47003    47214     +211     
+ Misses      36717    36686      -31     
- Partials     1787     1790       +3     

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Logo
Checkmarx One – Scan Summary & Detailsc55acea9-bd8c-4dcb-861a-cb2b7f4db046

New Issues (1)

Checkmarx found the following issues in this Pull Request

# Severity Issue Source File / Package Checkmarx Insight
1 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 431
detailsMethod at line 431 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 511

Copy link
Contributor

@amorask-bitwarden amorask-bitwarden left a comment

Choose a reason for hiding this comment

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

All the logic looks good, but the addition of new SPROCs need to be represented in the SQL project. See: https://github.com/bitwarden/server/blob/main/src/Sql/dbo/Stored%20Procedures/Organization_ReadById.sql

@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @kdenney's task in 4m 35s —— View job


Overall Assessment: REQUEST CHANGES

This PR adds database MaxStorageGb updates after Stripe reconciliation to fix an oversight where storage changes were only reflected in Stripe. The implementation includes comprehensive test coverage and proper tier detection (Personal vs Organization). However, critical data consistency issues between Stripe and database updates must be addressed.

Code Review Details

Critical Issues

  • CRITICAL: No transaction safety between Stripe and database updates creates unrecoverable data inconsistency
    • src/Billing/Jobs/ReconcileAdditionalStorageJob.cs:159

Important Issues

  • ⚠️ IMPORTANT: Counter incremented before verifying Stripe or database update success
    • src/Billing/Jobs/ReconcileAdditionalStorageJob.cs:115
  • ⚠️ IMPORTANT: Entity validation happens after Stripe update, creating orphaned subscription risk
    • src/Billing/Jobs/ReconcileAdditionalStorageJob.cs:306
  • ⚠️ IMPORTANT: Inconsistent error tracking makes monitoring difficult
    • src/Billing/Jobs/ReconcileAdditionalStorageJob.cs:176

Suggested Improvements

  • 🎨 SUGGESTED: Validate entity exists before updating Stripe to prevent orphaned updates
    • src/Billing/Jobs/ReconcileAdditionalStorageJob.cs:118

Key Concern: The metadata marking subscriptions as "reconciled" is set during the Stripe update (line 215), but database updates happen afterward. If the database update fails, the subscription is marked as processed and won't be retried, creating permanent inconsistency. This is a critical flaw in a billing reconciliation job where data accuracy is paramount.

Recommendation: Address the transaction safety issue before merging. Consider either setting metadata in a separate call after database success, implementing compensating transactions, or validating all prerequisites before modifying Stripe.

Copy link
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.

Few small DB changes needed.

@kdenney kdenney merged commit 3f2ee5b into main Jan 7, 2026
81 checks passed
@kdenney kdenney deleted the billing/PM-30460/storage-job-fix branch January 7, 2026 16:38
kdenney added a commit that referenced this pull request Jan 7, 2026
)

* [PM-30460] update storage job to also update database max storage

* dry run logs

* more logging fixes and pr feedback, forgot sql scripts

* claude feedback

* pr feedback, redesign of entity id reverse lookup

* claude feedback
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.

6 participants