fix: load safeupdate but disable for all but Data API#2027
fix: load safeupdate but disable for all but Data API#2027
Conversation
📝 WalkthroughWalkthroughAdds an up-only migration that configures PostgreSQL to load the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@nix/tests/sql/pg-safeupdate.sql`:
- Around line 15-18: The test grants schema privileges but not table privileges,
so the authenticated role lacks DELETE on v.foo; add an explicit table-level
grant (e.g., grant DELETE or GRANT ALL ON TABLE v.foo TO authenticated) before
switching role or running the DELETE so the test exercises safeupdate behavior
rather than permission errors; update the statements around GRANT ALL ON SCHEMA
v, set role authenticated, and the DELETE from v.foo accordingly.
🧹 Nitpick comments (1)
nix/tests/sql/pg-safeupdate.sql (1)
21-23: Minor: trailing blank lines.There are extra trailing blank lines at the end of the file that can be removed for cleanliness.
|
Failing on 15 because the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@migrations/db/migrations/20260130074514_load_disable_pg_safeupdate.sql`:
- Around line 2-3: The migration runs ALTER ROLE for the roles 'authenticated'
and 'anon' which will fail if those roles don't exist; update the migration to
guard those statements by checking for role existence first (e.g., query
pg_roles or use a DO block that checks IF EXISTS and only executes ALTER ROLE
when the role is present) so the ALTER ROLE session_preload_libraries =
'safeupdate' commands for roles 'authenticated' and 'anon' are applied
conditionally and the migration becomes idempotent.
|
@encima I think we should also announce this in https://github.com/orgs/supabase/discussions/categories/changelog, it's a "breaking change" in some cases I assume. |
|
@encima @steve-chavez if we do that we need to make it approx 3 week ahead of time change announcement per our breaking change process thanks for catching that @steve-chavez |
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
pg-safeupdate is only usable by the
authenticatorroleWhat is the new behavior?
pg-safeupdate is enabled by default for the
authenticatedrole - i.e. for the Data APICan be enabled for the
postgresuser by runningSET safeupdate.enabled=1;Additional context
Fixes #1308 (comment)
PSQL-910
Summary by CodeRabbit
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.