fix: deduplicate OG images to prevent unique constraint race (#287)#717
Open
pannous wants to merge 1 commit intoMerit-Systems:mainfrom
Open
fix: deduplicate OG images to prevent unique constraint race (#287)#717pannous wants to merge 1 commit intoMerit-Systems:mainfrom
pannous wants to merge 1 commit intoMerit-Systems:mainfrom
Conversation
…ondition (Merit-Systems#287) When scraped pages contain duplicate og:image tags pointing to the same URL, the parallel upsert calls within Promise.all race on the same compound unique key (originId, url), causing a unique constraint violation. Deduplicate OG images by URL before upserting so each URL is processed exactly once per batch.
Contributor
|
@pannous is attempting to deploy a commit to the Merit Systems Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Fixes a race condition during origin registration when scraped Open Graph metadata contains duplicate og:image URLs, by deduplicating images prior to performing batched Prisma upsert operations.
Changes:
- Deduplicate
origin.ogImagesbyurlbefore running thePromise.allupsert loop to avoid concurrent upserts of the same(originId, url)key.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #287 — OgImage unique constraint conflict during resource registration.
og:imagetags pointing to the same URL,Promise.allfires multipleupsertcalls with the same compound key(originId, url)simultaneously, causing a race condition and unique constraint violation.Mapkeyed by URL so the last occurrence wins (preserving the most recent metadata).Note: The original
@uniqueconstraint onurlalone was already removed in PR #472, which resolved the cross-origin conflict. This PR addresses the remaining within-batch race condition.Changes
apps/scan/src/services/db/resources/origin.ts: Added URL-based deduplication of OG images before thePromise.allupsert loop.Test plan