Skip to content

Commit 0c5ac16

Browse files
fix(billing): add err.stack + consistent stripeSessionId key to backfill logs
Fixes two logger.error calls (lines 332 and 344 of billing.webhook.service.js): - rename sessionId key to stripeSessionId for consistency with the rest of the file - add stack: err?.stack to both meta objects, matching surrounding logger.error style Also updates billing.refund-correlation unit test header comment to reference BillingFailedBackfillRepository.record instead of the stale BillingFailedBackfill.create.
1 parent dbb9c25 commit 0c5ac16

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const handleCheckoutPaymentCompleted = async (session) => {
328328
} catch (err) {
329329
logger.error(
330330
'[billing.webhook] PI metadata backfill failed after retries — refund correlation at risk',
331-
{ paymentIntentId, sessionId: stripeSessionId, error: err?.message ?? String(err) },
331+
{ paymentIntentId, stripeSessionId, error: err?.message ?? String(err), stack: err?.stack },
332332
);
333333
try {
334334
await BillingFailedBackfillRepository.record({
@@ -340,7 +340,7 @@ const handleCheckoutPaymentCompleted = async (session) => {
340340
} catch (dlqErr) {
341341
logger.error(
342342
'[billing.webhook] dead-letter write failed — manual reconciliation required',
343-
{ paymentIntentId, sessionId: stripeSessionId, error: dlqErr?.message ?? String(dlqErr) },
343+
{ paymentIntentId, stripeSessionId, error: dlqErr?.message ?? String(dlqErr), stack: dlqErr?.stack },
344344
);
345345
}
346346
}

modules/billing/tests/billing.refund-correlation.unit.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { retryWithBackoff } from '../lib/billing.retry.js';
99
*
1010
* Covers:
1111
* - retryWithBackoff: 3 attempts on Stripe API failure before escalating
12-
* - Dead-letter: BillingFailedBackfill.create called after 3 consecutive failures
12+
* - Dead-letter: BillingFailedBackfillRepository.record called after 3 consecutive failures
1313
* - Dead-letter write failure: logger.error emitted, handler does not throw
1414
*/
1515

0 commit comments

Comments
 (0)