GPT-5 finding
seed-outgoing-pr.ts claims idempotency but can throw on concurrent runs (no ON CONFLICT)
lowdocs-gaphigh
- apps/web/scripts/seed-outgoing-pr.ts:15-17
- apps/web/scripts/seed-outgoing-pr.ts:47-58
- apps/web/scripts/seed-outgoing-pr.ts:65-74
The script does a preselect-then-insert check for existing rows but does not use an upsert. Under concurrent invocation with identical args, a unique violation on outgoing_prs_upstream_uniq can occur, contradicting the stated idempotent behavior (a no-op) and causing the script to exit with an error.
Recommendation
Use an atomic upsert: insert ... on conflict (upstream_owner, upstream_repo, upstream_pr_number) do nothing returning id; if no row returned, select the existing id for logging. Alternatively, catch unique-violation errors and treat them as no-ops.