fix: deduplicate message IDs in saveChat to prevent ON CONFLICT error#713
Conversation
The AI state submit function uses a shared groupeId for multiple message types (response, resolution_search_result, related, followup), which all get the same ID. When onSetAIState calls saveChat, the batch insert hits: ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time (21000) Fix: Before inserting, scan for duplicate IDs within the batch and append a unique suffix to any duplicates, ensuring every row in the INSERT has a distinct primary key.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Someone is attempting to deploy a commit to the QCX-MAIN Team on Vercel. A member of the Team first needs to authorize it. |
|
ngoiyaeric seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 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
When the AI state
submitfunction builds messages, it uses a sharedgroupeIdfor multiple message types (response, resolution_search_result, related, followup), giving them all the same ID.When
onSetAIStatecallssaveChat, the batch insert hits:Fix
Before inserting,
saveChatnow scans for duplicate IDs within the batch and appends a unique suffix to any duplicates, ensuring every row in the INSERT has a distinct primary key.Files Changed
lib/actions/chat-db.ts— saveChat deduplication logic