-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permissions denied for table using API but works with SupabaseClient #4883
Comments
Update So I'm guessing that there is a lot going on under the hood when creating a table from the UI. There is any recommended way that I can create a table using functions and maintain the same functionalities as if it was being created in the UI? Thanks |
I am not sure if my issue is related: I am using:
I always get: The weird thing is: Before I was using |
I ran in the same error. (permission denied for table http_request_queue) My finding: It seems to be connected with the functions hooks ALPHA. After removing the hooks for the table that throws the error an insert was possible again. Adding the hook again leads to the same error. My instance was paused due to the holidays as well. Any ideas except setting up a new instance? |
Hi guys 👋 If you guys haven't, would you mind sending over a ticket specifying the affected project over at https://app.supabase.io/support/new, and we'll take a closer look at each one from there. Thanks! |
Ahhh! Why didn't I think of that?! I can confirm the behaviour: |
Hey folks-as a quick update: we've isolated the cause of the issue as an unfortunate interaction between the pause/restore and the mechanism used to enable function hooks via pg_net. We'll be working on both fixing this for the future, and posting a retroactive fix that you will be able to apply to your projects. |
@darora |
hello everyone!
if you're currently blocked please run the following in your Supabase SQL editor: GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role, dashboard_user;
ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
ALTER function net.http_collect_response(request_id bigint, async boolean) SECURITY DEFINER;
REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION net.http_collect_response(request_id bigint, async boolean) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role, dashboard_user;
GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role, dashboard_user;
GRANT EXECUTE ON FUNCTION net.http_collect_response(request_id bigint, async boolean) TO supabase_functions_admin, postgres, anon, authenticated, service_role, dashboard_user; |
🙏 Thanks. That solved the problem for me! |
Looks good on my end too 🎉 |
@w3b6x9 Thank you, this solved the issue for me. FYI this happened somewhere along following the lessons in your Egghead course. In lesson 24 I decided to delete the test user and signing up again was no longer possible. But my project has been paused once since I started the course so I guess it's more related to that than something instructed in the course? |
|
@jdahdah Sorry, completely missed your comment. I'll have the team look into this and report back here! There was another user who ran into the same issue and I'm trying to confirm now whether their project was also paused at one point. |
The comment left by @w3b6x9 solved the issue for me although I still see errors when logging in/out specifically |
A user on Discord, following one of the guides for setting up Stripe with an auth trigger to a profile table and then a function hook seems to be encountering this issue. After following the chain of debugging their trigger function and table set up finally they found the error in the logs, which I had seen here. "permission denied for table http_request_queue" I've asked them to contact support, unless they feel comfortable running the suggested SQL. https://discord.com/channels/839993398554656828/986571085724139550 |
I ran the suggested SQL and I can sign in but noticed some changes to my RLS policy. Make sure to review your policies after running the suggested SQL |
@oalbacha If you are creating users again, then you are on to some other issues in your code/setup. Probably best to ask in Discord or Github/Discussions here with details. |
I ran this code in the editor and since then, I have been unable to create new users. Also, I keep getting a type error: destroy is not a function. As I do not know how to rollback the code , I deleted my projects and organizations and created new ones hoping it would make a difference. It didnt. Then I created a new supabase account and I am still getting the errors. Is there any other thing I can do? |
Every time I try to make a request Does anyone know what could be the cause of this strange behavior? PSThe problem persists even when I create the new table using UI (website) (the rest of the tables are created using SQL queries). EDITI checked it with Supabase JS client - same result (even if service key was provided...) (also I didn't test the solution from this comment - too risky on this dataset 😅) EDIT2Pause/Restart? Nothing helped... lastEDITI found it! The cause of my problem... Maybe someone will find my "discovery" as useful. SQL query used to drop all :)DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public; |
This was it for me as well. Thank you for sharing. New project solved it. Would love to know if there's an alternative that doesn't require a new project in the future! |
The SQL queries in this thread did not help, but turning the |
How did you do this? |
In the left menu bar, go to database, then extensions, then look for |
Thank you, that did not work for me either. :( |
Thanks, this worked for me. I got the issue after upgrading postgresql version from the admin UI. |
Just got this after updating from 15.1.1.9 to 15.1.1.13 via the Admin UI. Disabling and reenabling the pg_net solved it. |
Ditto! |
@nahtnam Thank you for your comment. Saved me from deleting my entire database |
same here:
Thanks a lot @nahtnam ! |
how did you update the version via Admin Ui?? cant find that option |
@EricStrohmaier Go to the infrastructure tab in settings. |
Bug report
Describe the bug
When trying to access data from some API endpoints, like this: /rest/v1/leads?select=* I get this error:
when doing the same using JS client like this:
I successfully get the data. Although enabling or disabling RLS has no impact.
I'm using the same anon API key in both situations.
To Reproduce
I am creating these tables using the following function:
I tried to enable and disable RLS from UI and from SQL editor but didn't change anything.
I also tried to use the service role KEY when using API, but the same error above showed.
When creating the tables from the UI, everything seems to work as intended.
Expected behavior
I was expecting to be able to create tables programmatically from the client-side so I'm trying to do it using functions.
I'm using the function like this:
Am I missing something?
The text was updated successfully, but these errors were encountered: