Diag Auth Uid Null Jwt Sub Not Matching Auth Users Id

Concept Search related

The user applied migration 20260625_0009_align_member_id_with_auth.sql which:

The user's previous attempt to query current_setting('request.jwt.claims') returned "no rows" because the SQL Editor connection uses a service-role or psql connection that doesn't carry a user JWT. The only way to see the JWT claims is to make the iOS app itself call a function that reads request.jwt.claims (which diag_auth_uid() doesn't currently do explicitly — it only reads auth.uid(), auth.jwt()->>'email', and (auth.uid() IS NOT NULL)).

The fix: check the GoTrue config for the Apple provider. The correct config has apple_sub_as_user_id = true (or similar). If it's false (or unset, depending on GoTrue version), the JWT carries the Apple subject as sub, and auth.uid() returns the Apple subject as a UUID (which would be NULL because the Apple subject isn't a UUID — 000417.a617028500354e038cda2d22d8a3dbad.0229).

The user's session IS valid: session.user.id = 9DB7D397-... per the AuthService.currentMember DIAG. But auth.uid() returns NULL on the Postgres side. The rsvp sends member_id = currentMember.id = 9DB7D397-.... The RLS policy checks member_id = auth.uid(). Both should match. But auth.uid() is NULL → comparison is 9DB7D397... = NULL → false → RLS rejection.

How it's structured

  1. The pattern (verified 2026-06-25, Felt Faction iOS build, Option B durable-fix path) The user applied migration 20260625_0009_align_member_id_with_auth.sql which: member (Nate's row, fda2c638-...9db7d397-...) auth.us…
  2. The pattern (verified 2026-06-25, Felt Faction iOS build, Option B durable-fix path) After the migration applied, the user rebuilt + tried Claim Your Seat. Still failed with:
  3. The pattern (verified 2026-06-25, Felt Faction iOS build, Option B durable-fix path) [AppState.rsvp] failed: new row violates row-level security policy for table "event_attendance"
  4. The pattern (verified 2026-06-25, Felt Faction iOS build, Option B durable-fix path) The user ran the diag_auth_uid() function (still deployed from migration 20260624_0009). The output:
  5. The pattern (verified 2026-06-25, Felt Faction iOS build, Option B durable-fix path) The user's session IS valid: session.user.id = 9DB7D397-... per the AuthService.currentMember DIAG. But auth.uid() returns NULL on the…
  6. What this means (per `Honestly verification reports`) The schema is correct (members.id = auth.users.id). The iOS code sends the right UUID. The RLS policy is correct. But auth.uid() on the…
  7. … 5 more sections in the full essay

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