RPC function not working but no error is returned.
So I have my RPC function in supabase Database Functions. It was working at the first time but now for some reason it stopped working. My function have
row_id integer
argument:
and this is my js to run it:
Response of this rpc have no error or any specific data.
Any ideas?32 Replies
Can you share you whole function?
I mean rpc call is already written, and
.then
function content is not important because further actions are not doing anything with images table. It's just the problem with this supabase.rpc function.We need to view the whole function to make your it is being called correctly. Go go Database, click "Database Functions," click the menu next to it, and click "edit function" to get the full function code.
Well, this:
is entire code and It was working but not now.
no, with the input and everything
but that's everything I have here

You're not inputting anything, that is the problem. Delete your function, go to sql and type something like:
See if that works...
it gives an error
Failed to validate sql query: syntax error at or near "return"
Try:
same thing
ah... use
RETURNS
with an swell function now looks like this
and it's still not working
Run the above code in SQL, you need the WHOLE code, not just the middle part
I just done it
It created this database function
and it looks like this code above.
you ran it with RETURNS spelled correctly? Do you get an error?
yes
no errors in sql
but it's still not working
How is it not working?
that's good question
i looked up in api logs and postgres logs and saw no error either
If you run this straight in sql:
Does it work as expected?
yes it's working in sql
You could also do,
fwi
probably not the issue
ignore that, different sql
This should work, not sure why it doesn't. Not sure if it could be RLS or if you don't have the
plpgsql
extension installed?nah still not working
oh wow
ok the issue is rls
i just disabled it and now it's working
Yeah, I'm trying to figure out why you need it in functions...
but that's weird because normally I can UPDATE and INSERT without problems because I made rls policies for inserting and updating only for authenticated users.
but rpc is having problem with it
Perhaps @garyaustin can answer why functions use RLS, which is odd to me...
RLS applies to “security invoker” (default) functions. The tables they use must be accessible to the user making the call. So would work in SQL editor but not the API is anon or signed user can’t do the table operations. “Security definer” functions run as the user who created the function so usually bypass RLS.
So how would you write a function to get around the security access?
Add "security definer" to its definition .
It works now! Ty