[PM-40292] fix: Handle deleted Stripe customer on Admin user and provider edit pages - #8256
Conversation
…ider edit pages A deleted Stripe customer made the Admin Portal user and provider edit pages crash. The user page surfaced a StripeException from the payment- methods lookup in GetBillingAsync; the provider page threw a NullReferenceException dereferencing the deleted-customer stub's null Metadata in ApprovedToPayByInvoice. Both now degrade gracefully: billing state is skipped and the admin is warned to set a valid Gateway Customer ID, mirroring the organization fix from PM-38874.
…nvalid-customerid
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the Admin Portal handling of deleted Stripe customers across Code Review DetailsNo findings. Note: the |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8256 +/- ##
==========================================
+ Coverage 63.19% 63.55% +0.35%
==========================================
Files 2409 2430 +21
Lines 104393 105554 +1161
Branches 9453 9642 +189
==========================================
+ Hits 65971 67082 +1111
- Misses 36164 36169 +5
- Partials 2258 2303 +45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
Resolves PM-40292
📔 Objective
The Admin Portal user-edit and provider-edit pages returned a 500 when the subscriber's linked Stripe customer had been deleted. Retrieving a deleted Stripe customer returns an HTTP 200 stub (
Deleted = true,Metadata = null) instead of a 404, which produced two different crashes:GetBillingAsynccalls Stripe's payment-methods list endpoint, which does returnresource_missingfor a deleted customer, throwingStripeException.CustomerExtensions.ApprovedToPayByInvoicedereferenced the stub's nullMetadata, throwingNullReferenceException.Both pages now degrade gracefully, mirroring the organization fix from PM-38874:
UsersController.Edit(GET) wraps the billing loads in try/catch —resource_missingsurfaces a Warning toast, any other failure an Error toast, and both billing values reset to null so the page still renders.ApprovedToPayByInvoiceguards nullMetadata(fixing the root cause for all three callers), andProvidersController.GetEditModelsurfaces a Warning toast when the customer is a deleted stub.In every case the admin can still edit the page and set a valid Gateway Customer ID.
Tests: new
UsersControllerTestsandCustomerExtensionsTests, plus a deleted-customer case added toProvidersControllerTests.