Preview Database Isolation Fix#2185
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Here's a visual recap of what changed: Open the full interactive recap |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Builder reviewed your changes and found 2 potential issues 🔴
Review Details
Incremental Code Review Summary
The latest commit replaces the prior REVIEW_ID/fail-closed deployment approach with Netlify branch-scoped environment values. This removes the need to retry a failed preview and preserves the existing runtime variable names, while surgical deletion avoids removing values belonging to other branches. The workflow's explicit HTTP checks, jq payload construction, secret marking, and branch filtering are good patterns. One new standard-risk correctness issue remains in the POST/PATCH update path.
Key Finding
- 🟡 MEDIUM — Repeated PR updates may create duplicate branch-scoped Netlify values, while cleanup deletes only the first matching value. This can leave stale database credentials accumulated in the site environment and make subsequent value selection ambiguous.
The previously open preview-retry comment was verified fixed and resolved before this review.
🧪 Browser testing: Will run after this review (PR changes deployment/runtime configuration)

Every PR preview was sharing one database connection. When two PRs were open at the same time, opening or closing one could point another PR's preview at the wrong database — or break it entirely. This showed up as failed sign-ins and 502 errors on active previews, even though the setup workflow reported success.
The fix
Each PR preview now gets its own database, scoped to that PR's branch. Opening, updating, or closing one PR no longer affects any other PR's preview. Production is unaffected.
Everything is contained in
.github/workflows/neon-preview-branches.yml:Testing
Verified with two concurrent preview PRs: each had its own working database and sign-in, and opening or closing one did not affect the other.