Skip to content

Commit b25da05

Browse files
fix(billing): gate resolvePlan warn to metadata-absent case only
Copilot review finding on PR #3758: the previous warn fired whenever priceId was present and metadata didn't validate, but the log message said "metadata empty" — misleading when metadata IS present but invalid (validatePlan already warns in that case → double-warn). Gate: only emit the warn when rawMeta is also absent (!rawMeta), and update the message from "metadata empty" to "no metadata" to be precise.
1 parent 6ec833e commit b25da05

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

modules/billing/services/billing.webhook.service.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ const resolvePlan = (subscription) => {
100100
const rawMeta = item?.price?.metadata?.planId || item?.plan?.metadata?.planId;
101101
const fromMeta = validatePlan(rawMeta);
102102
if (fromMeta) return fromMeta;
103-
// Last-resort fallback — warn so misconfigured config.stripe.prices is visible
104-
// (otherwise this silently downgrades paid orgs to 'free', which is the exact bug #1250 fixed).
105-
if (priceId) {
106-
logger.warn('[billing.webhook] resolvePlan: priceId not in priceIdToPlan map and metadata empty — falling back to free', {
103+
// Last-resort fallback — warn only when metadata is also absent so misconfigured
104+
// config.stripe.prices is visible (otherwise this silently downgrades paid orgs to 'free',
105+
// which is the exact bug #1250 fixed). When metadata is present but invalid, validatePlan()
106+
// above already emitted an "unrecognized planId" warning — no double-warn needed.
107+
if (priceId && !rawMeta) {
108+
logger.warn('[billing.webhook] resolvePlan: priceId not in priceIdToPlan map and no metadata — falling back to free', {
107109
priceId,
108110
stripeSubscriptionId: subscription?.id,
109111
});

0 commit comments

Comments
 (0)