🐛 Fixed members list not loading (#12930)

refs https://github.com/TryGhost/Team/issues/660

In case stripe price for a subscription is missing in `stripe_prices` table, it will cause the API to load members list to fail with 500 as we try to serialize the stripe price on member subscription using empty object. This fixes the guard against populating price object for missing data in DB.

Note: This is only a short-term fix till we add a proper fix to cleanup the DB in the subsequent release.
This commit is contained in:
Rishabh Garg 2021-05-06 21:47:34 +05:30 committed by Rishabh
parent bea04e437d
commit 367b1a509f

View File

@ -1,4 +1,5 @@
const ghostBookshelf = require('./base');
const _ = require('lodash');
const StripeCustomerSubscription = ghostBookshelf.Model.extend({
tableName: 'members_stripe_customers_subscriptions',
@ -37,7 +38,7 @@ const StripeCustomerSubscription = ghostBookshelf.Model.extend({
current_period_end: defaultSerializedObject.current_period_end
};
if (defaultSerializedObject.stripePrice) {
if (!_.isEmpty(defaultSerializedObject.stripePrice)) {
serialized.price = {
id: defaultSerializedObject.stripePrice.stripe_price_id,
price_id: defaultSerializedObject.stripePrice.id,