[PM-40292] fix: Handle deleted Stripe customer on Admin user and provider edit pages - #8276
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
…nvalid-customerid
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the deleted-Stripe-customer handling across No findings. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8276 +/- ##
=========================================
+ Coverage 0 63.48% +63.48%
=========================================
Files 0 2430 +2430
Lines 0 104955 +104955
Branches 0 9506 +9506
=========================================
+ Hits 0 66631 +66631
- Misses 0 36031 +36031
- Partials 0 2293 +2293 ☔ 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.Views/Users/Edit.cshtmlguards the billing partial so a null billing model hides the section instead of crashing during render.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.