chore(supabase): config polish + lock down handle_new_user (PP-8hz) - #1309
Merged
Conversation
- admin.ts: prefer server-side SUPABASE_URL over NEXT_PUBLIC_SUPABASE_URL (admin client is server-only; SUPABASE_URL is the correct primary var) - env.ts: remove dead non-NEXT_PUBLIC fallbacks from publishable key chain (SUPABASE_PUBLISHABLE_KEY and SUPABASE_ANON_KEY never reach client bundles) - rls.ts: correct misleading JSDoc — Drizzle bypasses RLS via BYPASSRLS; withUserContext is for integration tests only, not app mutations - migration 0035: REVOKE EXECUTE on public.handle_new_user() from anon and authenticated (defense-in-depth, mirrors pattern from migration 0029) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Updates to Preview Branch (chore/supabase-config-polish) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
Contributor
There was a problem hiding this comment.
Pull request overview
Tightens up Supabase configuration handling and security posture by standardizing env-var precedence, clarifying RLS-related helpers’ intent, and revoking unnecessary access to a SECURITY DEFINER trigger function.
Changes:
- Prefer server-side
SUPABASE_URLfor the service-role admin client; simplifygetSupabaseEnv()publishable-key fallbacks toNEXT_PUBLIC_*variants only, and update unit tests accordingly. - Clarify
withUserContextdocs to reflect that Drizzle app queries bypass RLS and the helper is for test contexts. - Add migration
0035_lock_handle_new_userto revoke privileges onpublic.handle_new_user(); update Drizzle meta journal/snapshot.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/supabase/admin.ts | Prefers SUPABASE_URL for server-only admin client; updates missing-env error text. |
| src/lib/supabase/env.ts | Removes non-NEXT_PUBLIC_ publishable-key fallbacks and updates missing-env error text. |
| src/test/unit/supabase-env.test.ts | Updates env precedence tests to match the simplified key fallback chain. |
| src/server/db/utils/rls.ts | Rewords JSDoc to clarify intended usage for integration tests and non-RLS app authorization. |
| drizzle/0035_lock_handle_new_user.sql | Revokes privileges on the handle_new_user() trigger function (defense-in-depth). |
| drizzle/meta/_journal.json | Records the new migration entry. |
| drizzle/meta/0035_snapshot.json | Adds the schema snapshot for migration 0035. |
- rls.ts: replace NON-NEGOTIABLE #14 reference with stable file path (~lib/permissions/helpers); fix outdated role list to reference UserRole type - env.ts: clarify publishable key comment — not about client bundles but about which env names are typically set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced May 11, 2026
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
SUPABASE_URLoverNEXT_PUBLIC_SUPABASE_URL— the admin client isserver-onlyand the server-side var should take precedenceNEXT_PUBLIC_fallbacks (SUPABASE_PUBLISHABLE_KEY,SUPABASE_ANON_KEY) from the publishable key chain — these variables would never reach a client bundle, so the fallbacks were Vercel Marketplace migration cruftwithUserContext— Drizzle connects as a BYPASSRLS user so RLS is never enforced for app code; this helper exists only for integration tests that simulate RLS contextsREVOKE ALL ON FUNCTION public.handle_new_user() FROM anon, authenticated— defense-in-depth lockdown following the same pattern as migration 0029 (get_discord_config). The trigger function was created SECURITY DEFINER in migration 0007 but never had explicit EXECUTE revocations.Test Plan
pnpm run checkpasses (116 test files, 1033 tests all green)supabase-env.test.tsto remove the now-deleted fallback pathspnpm db:reset— verify migration 0035 applies andpnpm db:generatereports "No schema changes" (requires Supabase running locally; CI will exercise this via Supabase Branch Setup)Closes PP-8hz
🤖 Generated with Claude Code