How to safely diagnose PGRST202 for a missing Media Catalog RPC? #51514
Replies: 4 comments
|
PGRST202 means PostgREST couldn't find a function with that name and argument set in its schema cache. PGRST205 is the same error for a table or view. Your pg_catalog result (no we_media_catalog) already points to "object missing" rather than "cache stale". Here are read-only checks to confirm: -- 1. Migration history (the CLI records applied migrations here) Nothing in pg_proc/pg_class: the objects were never created. The fix is applying the migration that defines them, not a cache reload. |
|
You could have a look at https://github.com/pixeltable/pixeltable |
|
Building on @hippi345's existence checks — one branch of the PGRST202 tree they don't cover, and it's the one that's about to get much more common: the function exists, but the calling role has no EXECUTE privilege on it. PostgREST returns the same PGRST202 for that case, so existence checks alone can clear the wrong branch. The grant-level check (read-only, safe): -- Does the calling role actually have EXECUTE?
select has_function_privilege('anon', 'public.we_media_catalog(text)', 'EXECUTE') as anon_can,
has_function_privilege('authenticated', 'public.we_media_catalog(text)', 'EXECUTE') as auth_can;
-- And the raw ACL, including who granted:
select p.proname, p.proacl, pg_get_userbyid(p.proowner) as owner
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.proname ilike 'we_media%';
Schema exposure is the third look-alike: if the function lives outside the schemas PostgREST exposes ( On the schema cache: the reload trigger is Why this branch matters right now: Supabase's October 30 change stops auto-granting the platform roles access to newly created objects in existing projects. That means "object exists, role has no grant" becomes the default PGRST202/205 cause for anything created after that date — your four-way diagnosis (missing object / wrong signature / missing grant / stale cache) is exactly the protocol more people will need, and step 2 of it (the Your read-only instinct is right, by the way — every query in this thread reads |
|
One correction to the thread before the procedure, because it changes how you read the results: a missing EXECUTE grant does not produce PGRST202. PostgREST loads every function in the exposed schemas into its schema cache whatever the grants are. The privilege filter only applies to the OpenAPI output. So when the caller lacks EXECUTE, Postgres rejects the call and you get That leaves four causes for PGRST202/PGRST205:
Everything below is read only. Run it in the SQL Editor, which connects as -- 1. Migration history (written only by the Supabase CLI)
select version, name from supabase_migrations.schema_migrations order by version;
-- "relation does not exist" or 0 rows = the CLI never applied anything.
-- Objects created by hand in the SQL Editor never appear here, so use 2 as the source of truth.
-- 2. Do the objects exist anywhere, and with what signature?
select n.nspname, p.proname, pg_get_function_identity_arguments(p.oid) as args
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where p.proname ilike 'we_media%';
select c.relnamespace::regnamespace as schema, c.relname, c.relkind, c.relrowsecurity
from pg_class c where c.relname ilike 'we_media%';
-- 3. Only if 2 found something: grants and RLS policies
select p.oid::regprocedure,
has_function_privilege('anon', p.oid, 'execute') as anon_exec,
has_function_privilege('authenticated', p.oid, 'execute') as auth_exec
from pg_proc p where p.proname ilike 'we_media%';
select * from pg_policies where tablename ilike 'we_media%';How to read it:
Before you apply anything, take a copy, because the Free plan shows no backups. Run Sources:
|
Uh oh!
There was an error while loading. Please reload this page.
Hello Supabase Community,
I am diagnosing a Media Catalog API issue in my Watch & Earn project on the Supabase Free Plan.
PROBLEM
we_media_catalog(p_media: null)
READ-ONLY OBSERVATIONS
we_profiles, we_rewards, we_sessions, and we_videos.
"Last Backup: No backups".
IMPORTANT LIMITATIONS
These query results do not prove that the media objects are physically absent.
The authoritative migration history, installed definitions, permissions,
and PostgREST schema exposure/cache state have not been fully verified.
QUESTION
What is the safest read-only procedure to verify:
schema exposure, or stale PostgREST schema cache.
I want to diagnose the issue without risking existing user profiles,
sessions, points, or reward balances.
I have not applied migrations or refreshed the schema cache.
I do not want to run migrations until the production state and
recovery options are verified.
Thank you.
All reactions