Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Nov 20, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Payout queuing now only includes partners with a Stripe connection; the previous check against a payout-enabled timestamp was removed, improving which partners are selected for processing.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
dub Ready Ready Preview Nov 20, 2025 3:01am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 20, 2025

Walkthrough

Updates the Prisma query used by the Stripe payout cron to require that partners have a non-null stripeConnectId when grouping payouts by partner, and removes checks for payoutsEnabledAt.

Changes

Cohort / File(s) Summary
Payout partner query update
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts
Adjusted Prisma query: added requirement that partner.stripeConnectId is non-null when grouping payouts by partner; removed any payoutsEnabledAt check/references. No other control-flow or error-handling changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-file change; simple query predicate modification.
  • Check the updated Prisma query and any related indexes or schema expectations.

Possibly related PRs

Suggested reviewers

  • devkiran

Poem

🐰 I nibbled through code at night,
Stripe IDs now gleam in sight,
Payouts skip the null and stray,
Grouped by partner, hopped away,
Small tweak β€” the carrots line up right. πŸ₯•

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'Fix queueStripePayouts' is directly related to the main change: adding a Prisma query filter to the queueStripePayouts function to require non-null stripeConnectId.
✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-queue-stripe-payout

πŸ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 27cf2c6 and 507c44e.

πŸ“’ Files selected for processing (1)
  • apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1)

48-55: Consider adding observability logging for filtered partners.

Similar to the existing logging for missing chargeId (lines 32-40), consider logging when partners are filtered out due to missing stripeConnectId or payoutsEnabledAt. This would help with debugging if someone expects a payout to be queued but it isn't.

You could add logging after the query like this:

  const partnersInCurrentInvoice = await prisma.payout.groupBy({
    by: ["partnerId"],
    where: {
      invoiceId,
      status: "processing",
      mode: "internal",
      partner: {
        stripeConnectId: {
          not: null,
        },
        payoutsEnabledAt: {
          not: null,
        },
      },
    },
  });
+
+ // Log if no partners were found to help with debugging
+ if (partnersInCurrentInvoice.length === 0) {
+   await log({
+     message: `No eligible partners found for Stripe payouts in invoice ${invoiceId} (partners must have stripeConnectId and payoutsEnabledAt set)`,
+     type: "info",
+   });
+ }
πŸ“œ Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between edd4f55 and 27cf2c6.

πŸ“’ Files selected for processing (1)
  • apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
πŸ““ Common learnings
Learnt from: devkiran
Repo: dubinc/dub PR: 2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.
πŸ“š Learning: 2025-07-11T16:28:55.693Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.

Applied to files:

  • apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts
πŸ“š Learning: 2025-08-25T21:41:06.073Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2758
File: apps/web/app/(ee)/api/cron/payouts/balance-available/route.ts:43-45
Timestamp: 2025-08-25T21:41:06.073Z
Learning: For Stripe API calls on connected accounts, the stripeAccount parameter should be passed in the first parameter object (e.g., stripe.balance.retrieve({ stripeAccount })), not as request options in the second parameter.

Applied to files:

  • apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
πŸ”‡ Additional comments (1)
apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-stripe-payouts.ts (1)

48-55: Filter correctly prevents invalid Stripe payouts and follows established patterns.

The partner validation filters are defensive and necessary. Upstream validation in getPayoutEligibilityFilter already requires payoutsEnabledAt to be non-null for internal mode payouts at creation time, but webhooks can later disable payouts for partners, making the query-time checks essential. The pattern mirrors the already-deployed PayPal processing logic, which similarly filters for non-null payoutsEnabledAt. The stripeConnectId check is critical since Stripe transfers require a valid Connect account. If no partners match the filter criteria, the query gracefully returns an empty array with no side effects.

@steven-tey steven-tey merged commit 2407f3b into main Nov 20, 2025
7 of 8 checks passed
@steven-tey steven-tey deleted the fix-queue-stripe-payout branch November 20, 2025 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants