© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•8mo ago•
42 replies
Stan

Title: auth.uid() NULL issue with RLS enabled - Project ID: enzrjbcoxqtnxirlthps

Category: Q&A / Help (Choose one when creating the discussion)

Body:

Hi Supabase Team and Community,

I'm experiencing a critical issue where auth.uid() consistently returns NULL in my SQL Editor sessions, even after extensive troubleshooting. This is preventing my RLS policies from working.

My Project Reference ID: enzrjbcoxqtnxirlthps

Problem Description:
RLS is enabled, and policies are set up correctly. Data inserts work fine. However, simulating an authenticated user with SET request.jwt.claims.sub results in auth.uid() returning NULL, which blocks all RLS-protected queries.

Steps to Reproduce (in Supabase SQL Editor):

SQL

SET ROLE authenticated;
-- Alice's actual UUID, confirmed correct and exists in auth.users and public.students.
SET request.jwt.claims.sub = '03bfd497-c56d-4aed-b2dc-6a93a3ec495b';

SELECT auth.uid() AS current_session_uid_check; -- Expected: Alice's UUID, Actual: NULL

-- Example RLS test query (returns no rows due to auth.uid() being NULL)
SELECT id, first_name, last_name, present_class FROM public.students;

RESET ALL;
Troubleshooting Steps Taken:

Full Master Script Deployment: Successfully ran a comprehensive SQL script to create schema, enable RLS, and insert data. No errors.

UUID Confirmation: All UUIDs used (request.jwt.claims.sub, table inserts) are verified correct.

Data Insertion Confirmed: Data is correctly present in all tables (e.g., public.fees).

JWT Secret Regeneration: Regenerated JWT Secret from Project Settings -> API. No change to auth.uid() output.

RLS Policies Verified: SELECT pg_policies confirms all intended RLS policies are present and correctly defined for public.fees.

Table Name Confusion Resolved: Confirmed only public.fees table exists, no duplicate.

Impact: RLS policies cannot function, as the auth.uid() dependency is not resolving.

Any help or insights from the community or the Supabase team would be greatly appreciated!
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

RLS and auth.uid()
SupabaseSSupabase / help-and-questions
4y ago
Sometimes auth.uid() yields null
SupabaseSSupabase / help-and-questions
13mo ago
RLS policy including a auth.uid() statement
SupabaseSSupabase / help-and-questions
3y ago
Python: Insertion with RLS enabled
SupabaseSSupabase / help-and-questions
14mo ago