Replies: 3 comments
|
Your troubleshooting already isolates the interesting part: newly created functions 404 too, and neither A quick way to confirm it is a frozen cache rather than a privilege-resolution issue: compare the parameter shape the API error echoes with what the live catalog has ? select p.proname, pg_get_function_identity_arguments(p.oid)
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.proname = 'login';If the live signature differs in argument types (not just names) from what the API says it searched for, the API is resolving against the pre-migration definition ? a frozen cache, not a missing grant. A pure EXECUTE privilege problem would not touch brand-new zero-argument functions, and would not survive the Since this is hosted, you cannot restart PostgREST directly, but you can force a redeploy without touching data:
Two things worth ruling out while you wait, since the migration touched GRANT/REVOKE: -- PostgREST SET ROLEs from authenticator to these; all must be true
select pg_has_role('authenticator', r, 'member') as can_switch
from unnest(array['anon','authenticated','service_role']) as r;
-- API roles still need schema USAGE
select has_schema_privilege('anon','public','usage') as public_usage,
has_schema_privilege('anon','app_api','usage') as app_api_usage;If step 1 fixes it, it is worth reporting the trigger sequence (Management-API migration touching function signatures/grants ? silent listener death ? |
|
One thing doesn't fit the "frozen schema cache" theory: PostgREST builds the OpenAPI output at A security note for when RPC works again. select p.proname,
p.prosecdef as security_definer,
has_function_privilege('anon', p.oid, 'execute') as anon_can_execute
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
order by 1;New functions get EXECUTE for PUBLIC by default, so anon usually ends up with it. For admin-only functions: revoke execute on function public.admin_list_users() from public, anon;Also check |
|
The fact that the OpenAPI spec still lists every function while every RPC returns PGRST202 narrows this a lot, and it points at the matching layer rather than the cache itself: the schema cache has the functions (that is what the spec renders from), so something in how PostgREST resolves your call against those signatures fails for all of them. Three checks, in order — the first one is five seconds: 1. Parameter names, not positions, are what a JSON body matches on. PostgREST maps a JSON object to a function overload by parameter name. If the JSON keys do not match the function's parameter names exactly, resolution fails with exactly this error — including for functions you are sure exist. select p.proname,
pg_get_function_identityarguments(p.oid) as signature,
pg_get_functiondef(p.oid) like '%set search_path%' as has_set_clause,
p.proowner::regrole as owner
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
order by p.proname;Compare the 2. Zero-argument functions failing too is the tell. If -- force a reload; if RPCs work immediately after, the watch was broken
notify pgrst, 'reload schema';
-- and check the watch mechanism itself is present
select evtname, evtevent, evtowner::regrole from pg_event_trigger where evtname like 'pgrst%';
3. What changed on 2026-10-22. You wrote that the failure started that day. Before it, these functions presumably worked — so something in the pair (function set / project configuration) changed. The candidates worth diffing: functions created or replaced that day (a The practical sequence: run One thing this is not: not the anon-key exposure question, and not RLS — RPC 404 happens before policies are consulted, which is why the tables still work while every function fails. |
Uh oh!
There was an error while loading. Please reload this page.
Subject: Data API — all RPC calls return 404 PGRST202 (function not found) while table access and OpenAPI spec still work
Project ref: shpejvdbsplkqipfuuay
Region: ap-northeast-1 | PostgREST version: 14.5 (per pg_stat_activity)
Summary
) works normally, and GET /rest/v1/ (OpenAPI spec)Since 2026-10-22, EVERY RPC call to the Data API on this project returns HTTP 404 with
PGRST202: "Searched for the function public. ... but no matches were found in the schema cache."
Table access (GET/POST /rest/v1/
still lists all functions with correct signatures.
Reproduction (curl)
curl -i -X POST 'https://shpejvdbsplkqipfuuay.supabase.co/rest/v1/rpc/login'
-H 'apikey: '
-H 'Content-Type: application/json'
-d '{"p_username":"x","p_password":"y","p_hwid":"z"}'
HTTP/1.1 404 Not Found
{"code":"PGRST202",
"details":"Searched for the function public.login with parameter {...}, but no matches were found in the schema cache.",
"hint":null,
"message":"Could not find the function public.login({...}) in the schema cache"}
What I have verified1. Affects 100% of functions: also zero-argument functions (e.g. admin_list_users()), functions
created AFTER the incident, and functions in a newly created + newly exposed schema (app_api).
2. Same result with the publishable key (anon) and with the secret key (service_role).
3. Table endpoints work normally: RLS behaves correctly, service_role sees all rows.
4. GET /rest/v1/ returns the OpenAPI spec listing all 20 functions with correct signatures.
5. NOTIFY pgrst, 'reload schema'; does not help. DDL (CREATE TABLE / DROP TABLE) does not help.
6. pg_stat_activity shows "PostgREST 14.5" connected as role "authenticator" (NOINHERIT).
7. In Postgres the functions exist with correct signatures and grants
(PUBLIC/anon/authenticated/service_role); has_function_privilege('authenticator',
'public.login(text,text,text)','EXECUTE') = true. Owners are unchanged (postgres).
8. BEFORE 2026-10-22 RPC calls worked fine on this project (admin_list_users returned data
through the Data API with the legacy anon key).
9. The change coincides with SQL migrations applied through the Management API
(CREATE OR REPLACE FUNCTION changing a function signature + GRANT/REVOKE on functions).
Request
Could you please check and refresh the schema cache of the Data API for this project
(or restart the PostgREST service)? Failing that, please advise how to recover function
resolution — we currently have to route authentication through an Edge Function as a workaround.
Impact: the desktop app authenticates via POST /rest/v1/rpc/login, so users cannot sign in
until this is resolved.
All reactions