Persistent PGRST202 Error - RPC Calls Ignoring search_path / Custom Schemas #34737
Unanswered
hugoheadquarter
asked this question in
Questions
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm encountering a persistent
PGRST202error when trying to call PostgreSQL functions located in a custom schema (user) via RPC using thesupabase-jsclient (also tested withsupabase-py). Despite extensive troubleshooting, the API layer (PostgREST) consistently seems to search only thepublicschema, ignoring the configuredsearch_pathand exposed schema settings.Goal:
Call a function
user.add_song_like(p_user_id uuid, p_song_id uuid)from the client as an authenticated user.Problem:
When calling
supabase.rpc('add_song_like', { p_user_id: userId, p_song_id: songId }), I consistently receive the following error:{ "code": "PGRST202", "details": "Searched for the function public.add_song_like with parameters p_song_id, p_user_id or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache.", "hint": null, // Sometimes hints at unrelated public functions "message": "Could not find the function public.add_song_like(p_song_id, p_user_id) in the schema cache" }Database Setup:
userexists.add_song_like(p_user_id uuid, p_song_id uuid)exists within theuserschema. (It was previously namedadd_liked_song, renaming didn't help). Definition:user.liked_songsexists with appropriate columns (user_id uuid,song_id uuid, etc.) and RLS policies (SELECT, INSERT, DELETE usingauth.uid() = user_id).Configuration & Troubleshooting Steps Taken:
"user"(andtest_schemaduring later tests) is listed alongsidepublic,extensions.search_path: Confirmed via SQLALTER ROLE authenticated SET search_path = '"user"', public, extensions;(also tried variations withtest_schemafirst). Verified usingpg_catalog.pg_roles.GRANT USAGE ON SCHEMA "user" TO authenticated;andGRANT EXECUTE ON FUNCTION "user".add_song_like(uuid, uuid) TO authenticated;. Also granted toanonduring testing with no change.NOTIFY pgrst, 'reload schema';- No effect.select pg_terminate_backend(pid) from pg_stat_activity where application_name = 'postgrest';followed by waiting, including after schema/function/role changes - No effect on the error.add_liked_song->add_song_like) - Error persisted, just mentioning the new name but still searchingpublic.supabase.rpc('add_song_like', ...)-> Fails, searchespublic.add_song_like.supabase.rpc('"user".add_song_like', ...)-> Fails, searchespublic."user".add_song_like(incorrectly prependspublic.).public.add_song_like.console.logand Python script logs that validuuidstrings are being passed forp_user_idandp_song_id.test_schema.search_path(first).test_schema.echo_hello(message text).USAGEandEXECUTE.supabase.rpc('echo_hello', ...)still fails withPGRST202, indicating it searchedpublic.echo_hello.Question:
Given that all standard configurations (
search_path, Exposed Schemas, Grants) seem correct and even forceful cache clearing (pg_terminate_backend) doesn't resolve the issue, why would PostgREST consistently ignore thesearch_pathand exposed schemas for RPC calls and default to searching onlypublic? Is there any other project-level setting, potential bug, or deeper cache mechanism that could cause this behavior?Any insights or further diagnostic steps would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions