Sentry: NoMethodError zuora_account_id nil during subscription creation
Summary
Sentry event ff703c2b5d0e4806a9a8ef36edea4b17 shows NoMethodError: undefined method 'zuora_account_id' for nil when creating a new subscription in SubscriptionsController#create. The error originates in SubscriptionsFinder#raw_subscriptions when calling billing_account_or_customer.zuora_account_id, where billing_account_or_customer is nil.
Impact
Order creation fails for some customers during self-service subscription purchase, resulting in a 500 error.
Context
- Environment: production
- Release:
3c85a8e49d49925c6ffbf4ec8fb7cf833193cdb0 - Event time: 2026-02-12 08:46:28 UTC
- Request ID:
42ff4670-bd80-40f0-8479-0c37596b7e59 - Transaction:
SubscriptionsController#create - Customer:
1507892(olivier.dumont@vectr.consulting) - Subscription ID:
8a1290c09c2f5e62019c5107b02a5946 - Subscription name:
A-S00145410 - Plan ID:
2c92a0086a07f4a8016a2c0a1f7b4b4c
Stack trace (key frames)
-
app/finders/subscriptions_finder.rb:69raw_subscriptionszuora_account_id = billing_account_or_customer.zuora_account_id -
app/finders/subscriptions_finder.rb:28by_id_or_name -
app/services/create_order_service.rb:68load_subscription -
app/services/self_service/subscriptions/upsert_internal_objects.rb:56find_or_create_order -
app/controllers/subscriptions_controller.rb:115create
Suspected cause
billing_account_or_customer is nil in SubscriptionsFinder#raw_subscriptions during self-service purchase flow. This can happen when current_billing_account is missing and customer lookup doesn’t provide a fallback.
Proposed fix
- Guard against nil in
SubscriptionsFinder#raw_subscriptions, returning an empty set or a structured error whenbilling_account_or_customeris nil. - Add a clear error response for missing billing account in the purchase flow (before calling
CreateOrderService). - Add logging/metrics to detect when this condition occurs.
- Add a spec covering purchase flow with missing billing account.
Sentry link
Event ID: ff703c2b5d0e4806a9a8ef36edea4b17
Edited by Vitaly Slobodin