Skip to content
>_VibeUnstuck

Could not find the function in the schema cache

Last verified:

The fix

Could not find the function in the schema cache. PostgREST code PGRST202. The RPC name or its argument types are not in the cache. A missing column is PGRST204.

  1. 1

    Read the signature in the message

    The message names the schema, the function, and the arguments PostgREST looked up. The hint names the closest function, when there is one. Do not create a duplicate with a slightly different name until you have compared those two lines.

  2. 2

    Compare it to the function in the database

    In the SQL editor, list proname and pg_get_function_identity_arguments(oid) for that name. The .rpc object keys have to be the argument names, and the value types have to match. text is not uuid. Rename the key in the client, or the argument in a new migration, so they agree.

    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 = 'search_todos';
  3. 3

    Create the function only if that list is empty

    If no row comes back, the migration never ran on this project. Create the function in a migration, in the exposed schema, and grant execute to the role that calls it. Do not point .rpc at a table. A table is .from().

  4. 4

    Reload the cache after the signature already matches

    If the SQL list shows the same argument names and types the client sends, and the code is still PGRST202, reload the schema cache. Do not reload first. NOTIFY pgrst, 'reload schema'; is the SQL editor command. A permissions error after the function is found is 42501, not 202.

    NOTIFY pgrst, 'reload schema';

Why it happens

PostgREST looks up .rpc() in the schema cache, including the argument types. Its error reference describes PGRST202 as a stale function signature, or a function that is not in the database. The body is Could not find the public.my_function(args) function in the schema cache, using your schema and signature. The docs' example is Could not find the api.nonexistent_function() function in the schema cache. hint is often Perhaps you meant to call the function public.my_function.

The name can exist and still miss. .rpc("search", { query: "bags" }) does not match search(q text) because the argument name differs. Overloaded functions with the same argument names and different types return PGRST203, not this code. A missing column on an insert is PGRST204, Could not find the 'title' column of 'posts' in the schema cache. A missing table is PGRST205. Reloading the cache does not create a function.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Could not find the column in the schema cache. PostgREST refused a write because that column name is not in its schema cache. The body is PGRST204: Could not find the 'title' column of 'posts' in the schema cache.

Prompt to paste back into your AI tool

Paste this above the error.

Supabase/PostgREST returns 404 PGRST202: Could not find the function <signature> in the schema cache. hint: <hint or none>. The call is supabase.rpc(<name>, <args>).

Do not disable RLS. Do not grant the service role to the browser. Do not reload the schema cache before comparing the signature. Do not create a second function with a near-duplicate name. If the code is PGRST204, stop. That is a column.

1. Show proname and pg_get_function_identity_arguments for this name.
2. If a row exists, change the .rpc argument names and types to match it, or change the function in one migration so they match.
3. If no row exists, the function was never created here. Add that migration. Do not call a table through .rpc.
4. If the signature already matches, tell me to run NOTIFY pgrst, 'reload schema'; in the SQL Editor.

Common questions

+The function is in the dashboard and the API still says PGRST202. Why?

The arguments do not match, or the schema cache is stale. Compare pg_get_function_identity_arguments to the keys you pass to .rpc. Reload with NOTIFY pgrst, 'reload schema' only after those match.

+PGRST204 mentions the schema cache too. Is that this error?

No. PGRST204 is a column on an insert, update, or upsert. PGRST202 is an RPC function. PGRST205 is a table. Use the code in the body.

Related errors