Make the session-refresh test own every Supabase env var it reads - #206
Merged
Conversation
CI failed on "refreshes an expiring session for a browser and writes the new tokens back" with `expected '***' to be 'anon-key'`: the test stubbed SUPABASE_ANON_KEY but refreshSession prefers NEXT_PUBLIC_SUPABASE_ANON_KEY, which CI sets to the real key. The URL pair has the opposite precedence, so that half passed by luck. Stub all four variables so the test passes with and without real keys in the environment. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJaXiqE9BDoNfoJBhfXroC
ThreatCrush Security Scan99 finding(s) HIGH/CRITICAL: 11 | MEDIUM: 29 | LOW: 59
…and 49 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
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.
Fix for the deterministic CI failure introduced by #205
Run Testson master (runs 33978537165, 33978629242) failed onsrc/proxy.test.ts > Supabase session refresh and referral cookie > refreshes an expiring session for a browser and writes the new tokens backwithexpected '***' to be 'anon-key', which blocks the droplet deploy.Cause.
refreshSessionreadsprocess.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEYat call time. The test stubbed onlySUPABASE_ANON_KEY, so in CI the realNEXT_PUBLIC_SUPABASE_ANON_KEYwon. The URL pair has the opposite precedence (SUPABASE_URLfirst), which is why that assertion passed. Not an import-time read; the env is read lazily inside the function.Fix. The test stubs all four variables (
SUPABASE_URL,NEXT_PUBLIC_SUPABASE_URL,SUPABASE_ANON_KEY,NEXT_PUBLIC_SUPABASE_ANON_KEY) inbeforeEachand unstubs inafterEach, so it owns every value the code can read. One-file change, no production code touched.Proof.
NEXT_PUBLIC_SUPABASE_ANON_KEY=real-looking-key NEXT_PUBLIC_SUPABASE_URL=https://x.supabase.co: 1 failed,expected 'real-looking-key' to be 'anon-key'(CI's failure reproduced).SUPABASE_URL/SUPABASE_ANON_KEYset to other values): 27 passed.pnpm test: 2731 passed, 9 skipped, 0 failed.pnpm typecheck: clean.pnpm lint: 0 errors (248 pre-existing warnings).🤖 Generated with Claude Code
https://claude.ai/code/session_01WJaXiqE9BDoNfoJBhfXroC