From 5845881b08bfa08fb25d951bbb050354d5183938 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Tue, 9 Jan 2024 14:48:07 -0800 Subject: [PATCH] chore: Handle stripe events without plan data (#8668) `plan` isn't a guaranteed object in stripe `customer.subscription.updated` events. It can be null for cases like `send_invoice` for `past_due` event as seen in the payload shown in sentry error. fixes: https://linear.app/chatwoot/issue/CW-2925/nomethoderror-undefined-method-[]-for-nilnilclass-nomethoderror --- .../services/enterprise/billing/handle_stripe_event_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb b/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb index fecc52e03..1ddf00d7a 100644 --- a/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb +++ b/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb @@ -14,7 +14,8 @@ class Enterprise::Billing::HandleStripeEventService private def process_subscription_updated - plan = find_plan(subscription['plan']['product']) + plan = find_plan(subscription['plan']['product']) if subscription['plan'].present? + # skipping self hosted plan events return if plan.blank? || account.blank?