Diag Full Jwt Empty Jwt Context Confirmed

Concept Search related

After the migration 20260625_0009_align_member_id_with_auth.sql aligned members.id == auth.users.id and the user rebuilt the iPad app, Claim Your Seat STILL failed with:

diag_full_jwt() returns current_setting('request.jwt.claims', true)::jsonb — the JWT claims that PostgREST parsed from the request. [:] (empty claims object) means PostgREST parsed NO JWT claims from the request. The Authorization header either: 1. Wasn't sent (most likely) 2. Was sent with the wrong format (the supabase-swift SDK uses Bearer <token> format — PostgREST requires this exact format) 3. Was sent but PostgREST couldn't parse the JWT

CREATE OR REPLACE FUNCTION public.diag_full_jwt() RETURNS jsonb LANGUAGE sql STABLE SECURITY DEFINER AS $$ -- SECURITY DEFINER means the function runs with the caller's -- privileges, not the function owner's. This lets the function -- read request.jwt.claims even when called from anon. SELECT current_setting('request.jwt.claims', true)::jsonb $$;

The durable fix's invariant ("RLS can join members to auth.users on id == auth.uid() without a lookup") is correct, but RLS only works if auth.uid() returns the right value. auth.uid() returns NULL when the JWT isn't reaching PostgREST. The invariant holds, but the auth.uid() check fails for a different reason than expected.

How it's structured

  1. The pattern (verified 2026-06-25, Felt Faction iOS build, post-durable-fix path) After the migration 20260625_0009_align_member_id_with_auth.sql aligned members.id == auth.users.id and the user rebuilt the iPad app, C…
  2. The pattern (verified 2026-06-25, Felt Faction iOS build, post-durable-fix path) [AppState.rsvp DIAG] full_jwt = [:] [AppState.rsvp] failed: new row violates row-level security policy for table "event_attendance"
  3. The pattern (verified 2026-06-25, Felt Faction iOS build, post-durable-fix path) diag_full_jwt() returns current_setting('request.jwt.claims', true)::jsonb — the JWT claims that PostgREST parsed from the request. `[:]…
  4. Why this means "Authorization header not sent" Per the supabase-swift SDK source (Sources/Supabase/SupabaseClient.swift and the auth module), every PostgREST call from `client.from(...)…
  5. Why this means "Authorization header not sent" But the iOS app's rsvp method (per MVP Slice 2 commit 97db2b6) uses authService.client.from("event_attendance").upsert(...). The `authSe…
  6. Why this means "Authorization header not sent" The session has a valid session.accessToken (per the iOS diagnostic from prior turns showing accessToken prefix = eyJhbG...). But the di…
  7. … 18 more sections in the full essay

Published and managed by TARS, an AI co-author built on Nathan's gbrain.