Skip to content
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

Cannot use safeupdate for the database nor the postgres user (session_preload_libraries) #1308

Open
2 tasks done
activenode opened this issue Jun 22, 2024 · 21 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@activenode
Copy link

Bug report

Basically, this worked in older projects. In newer projects, the permissions are stricter and one cannot enable this, safeguarding, safeupdate extension. But this is a crucial help for avoiding human failure.

-- 1. doesn't work
GRANT SET ON PARAMETER session_preload_libraries TO postgres;
ALTER ROLE postgres SET session_preload_libraries = 'safeupdate';

-- 2. also doesn't work
alter database postgres set session_preload_libraries = 'safeupdate';


-- test
CREATE TABLE IF NOT EXISTS todos (id SERIAL NOT NULL PRIMARY KEY, title TEXT);
INSERT INTO todos (title) VALUES ('test-todo-123');

DELETE FROM todos; -- should fail with safeupdate
  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

It's all said.

To Reproduce

Try either of the provided options in the intro.

Expected behavior

safeupdate can be enabled in the database (I don't think we necessarily need postgres role setting but rather one config that enables this in the database or not).

Screenshots

image
@activenode activenode added the bug Something isn't working label Jun 22, 2024
@encima
Copy link
Member

encima commented Jun 24, 2024

Hi @activenode ,

Thanks for opening. Can you confirm your instance is running the latest version: 15.1.1.64?

Trying both options work for me with the anon and postgres users.

Enabling it for the entire database is the second option, per user can be useful for those using the API or wanting to enforce it in to more specific use cases.

@activenode
Copy link
Author

I've created a new project on supabase.com and tried this. I can do it again. Will get back to you soon

@activenode
Copy link
Author

(I need to add: This is definitely still possible with older projects if you've tried that)

@activenode
Copy link
Author

I deleted my test project and created a new one.

image

image

image

@activenode
Copy link
Author

Can you confirm this? @encima ?

@encima
Copy link
Member

encima commented Jun 27, 2024

hey @activenode
just tried with a new project and cannot confirm 😕
If you run the 2 commands separately, do you experience this also?

I just tried running both as a single transaction and 2 separate ones without issue 🤔

@activenode
Copy link
Author

Will create a new one and make a video

@activenode
Copy link
Author

Completely fresh project on supbase.com (I try setting it first, then altering, then trying again, just to show it doesn't work no matter what I do)

ne.mov

@activenode
Copy link
Author

Also tried it now on a FRESH npx supabase init instance. Same problem. I'm not sure which kind of magic instance you have which I don't :D

@activenode
Copy link
Author

Just to give it another way of trying, I also added it now to a migration file and called npx supabase db reset . Same thing

image

image

@Firas752
Copy link

My team is facing the same issue actually

@Cuzart
Copy link

Cuzart commented Jun 28, 2024

I just followed the instruction from the docs with replacing "anon" by postgres and I also get a permission denied error (ERROR: 42501)

@imownbey
Copy link

I am seeing the same error

@encima
Copy link
Member

encima commented Jul 1, 2024

Hey folks, thanks for confirming these!

What I have found in testing is this:

  • New projects do not have this issue
  • Old projects do not have this issue
  • Old projects updated to the latest version DO have this issue

Can you confirm this is what you are experiencing as well?

Update: it seems like the comments above are from new projects so there is not much of a pattern 🤷‍♀️

@activenode
Copy link
Author

What I have found in testing is this:
New projects do not have this issue
Old projects do not have this issue
Old projects updated to the latest version DO have this issue

Cannot confirm. Happens for new projects as well as happened for old projects on my end.

What I can confirm though is: On SOME old projects it worked.

@Cuzart
Copy link

Cuzart commented Jul 1, 2024

For me this also appeared on a freshly created project

@encima
Copy link
Member

encima commented Jul 1, 2024

Thanks folks, this has been escalated to @supabase/postgres and I will get back here when we know more

@encima
Copy link
Member

encima commented Jul 2, 2024

Hey all, quick update from our side:

This issue is being resolved through our included utils library supautils and the documentation will be updated to reflect the steps. It is a bug that you are able to set session_preload_libraries as it needs superuser access and should go through the supautils interface.

We will link the PR when it is out and then update the documentation to reflect the changes.

Thanks for reporting this and for your patience!

@imownbey
Copy link

imownbey commented Jul 9, 2024

Any update on this?

@encima
Copy link
Member

encima commented Jul 9, 2024

Any update on this?

hey @imownbey update to the docs incoming tomorrow but we have a fix in place that is implemented by supautils.

@encima
Copy link
Member

encima commented Jul 16, 2024

Hello all,

It has been identified that modifying safeupdate such that it is loaded for all projects and enabled globally can impact other extensions that also require shared libraries (i.e. Timescaledb). It has caused a few support issues so, while we investigate further, it will be disabled as an extension and we will temporarily hide the page from the docs.

Apologies for the inconvenience, we really want to make sure that we minimise breaking changes and maintain a consistent experience as much as possible.

@olirice olirice transferred this issue from supabase/supabase Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants