fix: handle OgImage unique constraint conflict for shared URLs across origins#822
Open
artylobos wants to merge 1 commit into
Open
fix: handle OgImage unique constraint conflict for shared URLs across origins#822artylobos wants to merge 1 commit into
artylobos wants to merge 1 commit into
Conversation
… origins Fixes Merit-Systems#287 The registration crash occurs when two different origins share the same OG image URL (e.g. via shared CDN or redirect). The root cause is twofold: 1. Within a single origin: duplicate og:image tags with the same URL cause parallel upserts with the same composite key, creating a race. 2. Across origins: if migration 20260115100000 hasn't been applied in production, a legacy unique index on OgImage.url still exists, causing P2002 errors when a URL is already stored under another origin. Fix: - Deduplicate OG images by URL within each origin (prevents race) - Wrap upsert in try/catch for Prisma P2002 unique violation - Gracefully skip if OgImage URL already exists for another origin (no data loss — the image is already stored)
Contributor
|
@artylobos is attempting to deploy a commit to the Merit Systems Team on Vercel. A member of the Team first needs to authorize it. |
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
Problem
When registering a new resource, registration fails with a database unique constraint error if two different origins share the same OG image URL (e.g., via shared CDN or redirect).
Root Cause
Fix
Changes
Modified apps/scan/src/services/db/resources/origin.ts:
Testing
This fix handles both scenarios described in #287: