accessing values set in app_metadata security definer

Following the managing user data guide https://supabase.com/docs/guides/auth/managing-user-data I have got users profiles created when a user signs up.

However I am also storing a user role within the app_metadata object.

When I try and access this value within the security definer using new.raw_app_meta_data->'role' I get null.

If I raise log '%', new.raw_app_meta_data; I get {"provider": "email", "providers": ["email"]}.

Whereas in auth.users.raw_app_meta_data I can see {"role":"admin","provider":"email","providers":["email"]}.

Why is my role not available within the new object?
Supabase Documentation
Securing your user data with Row Level Security.
Was this page helpful?