Agree the test harness escape with resolveDatabaseUrl()'s variable order - #1547
Conversation
…variable order The harness's DATABASE_URL-only escape and the application's resolveDatabaseUrl() (DIRECT_DATABASE_URL first, then DATABASE_URL) disagreed about which variable counts, so a DIRECT_DATABASE_URL-only environment silently ran the suite on PGlite instead of the named server. readDatabaseEscape() now walks the same CONNECTION_VARIABLES list url.ts exports, checked in the same order, so the two lookups cannot drift apart again. A set-but-unusable value in either variable still fails loudly, naming the variable and both remedies. Closes #1210 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018peyBGVF5g4MX7qUiq68UG
|
Deployment failed for project stack-docs with the following error: Learn More: https://vercel.com/open-saas?upgradeToPro=build-rate-limit |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
🦋 Changeset detectedLatest commit: 7f3fe58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code ReviewI reviewed this PR's diff against Result: no blocking issues found.
One optional, non-blocking observation (pre-existing, not introduced by this diff): No changes requested; this is good to merge from a correctness standpoint. Generated by Claude Code |
…d of a private copy The suite carried its own classification of DIRECT_DATABASE_URL/DATABASE_URL, duplicating the exact logic #1210 unified in testing/escape.ts. Already correctly ordered, so no behavior change — this just removes the second copy that could have drifted from the shared one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018peyBGVF5g4MX7qUiq68UG
|
Addressed the review's nit: Generated by Claude Code |
|
The Generated by Claude Code |
|
The This isn't this PR's failure: the diff touches only Re-running the failed job once to confirm. Generated by Claude Code |
Coverage Report for Core Package Coverage (./packages/core)
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Coverage Report for UI Package Coverage (./packages/ui)
File CoverageNo changed files found. |
Coverage Report for CLI Package Coverage (./packages/cli)
File CoverageNo changed files found. |
Coverage Report for Auth Package Coverage (./packages/auth)
File CoverageNo changed files found. |
Coverage Report for Storage Package Coverage (./packages/storage)
File CoverageNo changed files found. |
Coverage Report for RAG Package Coverage (./packages/rag)
File CoverageNo changed files found. |
Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)
File CoverageNo changed files found. |
Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)
File CoverageNo changed files found. |
Summary
resolveDatabaseUrl()(packages/core/src/db/url.ts) readsDIRECT_DATABASE_URLfirst, thenDATABASE_URL. The test harness's escape (packages/core/src/testing/escape.ts) only ever readDATABASE_URL, so an environment with onlyDIRECT_DATABASE_URLset silently fell back to in-process PGlite while the application would have used a real Postgres — a quiet divergence rather than a loud one.packages/core/src/db/url.tsnow exportsCONNECTION_VARIABLES, the one place the ordered variable list is written down.packages/core/src/testing/escape.tsre-exports it asESCAPE_VARIABLESandreadDatabaseEscape()walks it in the same orderresolveDatabaseUrl()uses — the first variable that is set and non-empty wins, soDIRECT_DATABASE_URLalone is classified exactly as the application would resolve it.DatabaseEscape's'unusable'variant andUnusableDatabaseEscapeErrornow carry the actual variable name, so a set-but-unusable value still fails loudly naming the variable, its value, the fault and both remedies (unchanged pattern from The Dev database primitive and a URL lookup with provenance #1197) — whichever of the two variables was the culprit.ESCAPE_VARIABLEtoESCAPE_VARIABLESacross every consumer (skip-reason messages incore's andrag's test suites); no production behavior change outside@opensaas/stack-core.pglite-absence.test.tsnow clears both connection variables before asserting the PGlite-missing path, matching the harness's real lookup.Test plan
packages/core/src/testing/escape.test.ts: unit coverage forreadDatabaseEscape()/requireUsableDatabaseEscape()— absent,DATABASE_URLalone,DIRECT_DATABASE_URLalone (the bug fix),DIRECT_DATABASE_URLwinning overDATABASE_URL, an unusable value in either variable (including an unusableDIRECT_DATABASE_URLoutranking a usableDATABASE_URL, matchingresolveDatabaseUrl()'s order), and the thrown error naming the variable and both remedies.pnpm buildinpackages/core(typecheck)pnpm testinpackages/core— 1767 passed, 7 skippedpnpm build+ targetedvitest runinpackages/ragfor the two touched suites — 30 passedpnpm lint,pnpm format,pnpm manypkg fixat the repo root — clean@opensaas/stack-core(patch)Closes #1210
🤖 Generated with Claude Code
https://claude.ai/code/session_018peyBGVF5g4MX7qUiq68UG
Generated by Claude Code