Improve partner invites / default link updates - #4291
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@coderabbitai full review, any breaking changes? |
|
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR changes partner-group default-link updates and adds rate limiting and error propagation for partner-profile invitations. ChangesDefault-link updates
Partner invitation controls
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PATCHHandler
participant DefaultLinkTransaction
participant Program
PATCHHandler->>DefaultLinkTransaction: update default-link URL and UTM parameters
DefaultLinkTransaction->>Program: update program URL for the default partner group
DefaultLinkTransaction-->>PATCHHandler: return updated link or duplicate-URL error
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts (1)
72-101: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftKeep domain and URL changes in one transaction.
Lines 72-91 commit the domain change before the URL update at Lines 103-131. If the URL update fails with
P2002, the route returns a conflict but leaves the program domain and all default-link domains changed. It also schedulesqueueDomainUpdatefor that partial state.Include the domain writes and URL writes in one transaction. Schedule
queueDomainUpdateonly after that transaction succeeds.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/app/`(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts around lines 72 - 101, Update the route’s transaction flow so the program/default-link domain updates and the URL update operations are executed together in a single prisma.$transaction, allowing URL conflicts to roll back all changes. Move queueDomainUpdate out of the transaction and schedule it only after the combined transaction completes successfully, preserving the existing domain values passed to it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/web/app/`(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts:
- Around line 161-162: Update the no-URL-change response in the default-link
route to return the persisted domain value when a domain-only update occurs.
Ensure the object passed to PartnerGroupDefaultLinkSchema.parse uses the updated
domain while preserving the existing defaultLink fields and response behavior
for requests with no changes.
- Around line 121-130: Update the transaction construction in the default-link
route to ensure the prisma.$transaction array contains only Prisma
queries/promises: conditionally include the program update for
DEFAULT_PARTNER_GROUP, or switch to an interactive transaction and call
tx.program.update only when the group matches. Preserve the existing update data
and skip it for other groups.
---
Outside diff comments:
In
`@apps/web/app/`(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts:
- Around line 72-101: Update the route’s transaction flow so the
program/default-link domain updates and the URL update operations are executed
together in a single prisma.$transaction, allowing URL conflicts to roll back
all changes. Move queueDomainUpdate out of the transaction and schedule it only
after the combined transaction completes successfully, preserving the existing
domain values passed to it.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4c797763-bb00-4257-a0c4-a7b3b851e00f
📒 Files selected for processing (4)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.tsapps/web/app/(ee)/api/partner-profile/invites/route.tsapps/web/lib/api/partners/invite-partner-user.tsapps/web/lib/upstash/ratelimit-policies.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts (1)
72-131: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftMake the full default-link PATCH atomic.
domainchanges commit at Lines 73-88 before the URL update transaction starts at Lines 105-131. If the default-link URL update hits aP2002conflict, the returned409leaves the program domain and default-link domains already changed. Move the domain and URL writes into one interactional Prisma transaction, and queuequeueDomainUpdateand publish the QStash job only after it succeeds.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/app/`(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts around lines 72 - 131, Make the PATCH handler’s complete default-link update atomic by moving the domain updates and URL/default-group program updates into a single Prisma transaction. Ensure a URL uniqueness conflict rolls back every write, and invoke queueDomainUpdate plus any QStash publishing only after the transaction succeeds; update the surrounding PATCH flow rather than changing the individual update payloads.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/api/partners/invite-partner-user.ts`:
- Line 41: Update the route handler in route.ts that catches rejections from
invitePartnerUser to rethrow existing DubApiError instances unchanged,
preserving their codes, and convert unexpected errors into an appropriate 5xx
DubApiError response. Keep invitePartnerUser’s throw error behavior intact.
---
Outside diff comments:
In
`@apps/web/app/`(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.ts:
- Around line 72-131: Make the PATCH handler’s complete default-link update
atomic by moving the domain updates and URL/default-group program updates into a
single Prisma transaction. Ensure a URL uniqueness conflict rolls back every
write, and invoke queueDomainUpdate plus any QStash publishing only after the
transaction succeeds; update the surrounding PATCH flow rather than changing the
individual update payloads.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 20682e11-c10e-490e-a492-6a394de8b09e
📒 Files selected for processing (4)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/default-links/[defaultLinkId]/route.tsapps/web/app/(ee)/api/partner-profile/invites/route.tsapps/web/lib/api/partners/invite-partner-user.tsapps/web/lib/upstash/ratelimit-policies.ts
Summary by CodeRabbit
New Features
Bug Fixes