fix(worker): log auto top-up card declines at warn#2969
Conversation
Card declines (insufficient funds, generic_decline, expired cards, etc.) are an expected outcome of an off-session auto top-up, not a server error. Detect StripeCardError and log it at warn level so it no longer triggers ERROR-severity alerts; genuine Stripe failures still log at error level. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe processAutoTopUp Stripe error handling path was updated to normalize caught errors into an Error instance and log card-decline errors (StripeCardError) at warn level, while other Stripe errors continue to log at error level. ChangesStripe Error Logging Update
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
An off-session auto top-up charge that Stripe declines (
code: card_declined,decline_code: generic_decline, etc.) was surfacing in the worker as alogger.error— ERROR severity — which fired production error alerts:A card decline is an expected outcome of charging a saved card off-session, not a server error.
Fix
In
processAutoTopUp()'s catch block, detectStripe.errors.StripeCardError(insufficient funds, generic_decline, expired card, etc.) and log it atlogger.warninstead oflogger.error. Genuine, unexpected Stripe failures still log at error level and continue to alert.This mirrors the existing pattern already used in
apps/api/src/routes/payments.tsand the webhook failure handler, which log payment declines at warn level.Notes
failedexactly as before.pnpm build(worker) andpnpm formatpass.🤖 Generated with Claude Code
Summary by CodeRabbit