Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

New Supabase tables can return 42501. Old ones can still be readable.

If you shipped a Supabase app with Lovable, Cursor, or another AI coding tool, two things may show up at once: a new table fails with Postgres error 42501 (permission denied for table), or someone asks whether the Octobe

If you shipped a Supabase app with Lovable, Cursor, or another AI coding tool, two things may show up at once: a new table fails with Postgres error 42501 (permission denied for table), or someone asks whether the October 30 Data API change closed off tables you created earlier.

Those are not the same problem. They sit on two layers of Postgres access control, and mixing them up is how a 42501 fix turns into a table that signed-out visitors can read. This review is for your project, not anyone else's, and it is not legal advice.

What actually changed

On April 28, 2026, Supabase published a breaking-change notice: new tables in the public schema would no longer be reachable through the Data API automatically. The planned dates were April 28 (opt in at project creation), May 30 (new default for new projects, rolled out gradually), and October 30, 2026 (applied to existing projects).

The Data API is the auto-generated REST and GraphQL layer that supabase-js and the other client libraries call (/rest/v1/ and /graphql/v1/). Direct Postgres connections are unaffected.

Once the new default is active, a table you create in public exists, but the Data API cannot see it until you issue an explicit GRANT. Existing tables keep their current grants and stay reachable.

Supabase's API docs still describe automatic grants on some existing projects and tell you to inspect your own defaults. As of this draft (November 25, 2026), I have not seen a later official changelog post confirming that every existing project has switched. Treat October 30 as the announced date, then check your project.

Grants and RLS are two layers

  1. Grants decide whether a role can reach a table, view, or function through the Data API at all. The roles that matter here are anon (signed-out requests), authenticated (signed-in users), and service_role (server-side).
  2. Row Level Security (RLS) policies decide which rows that role can read or change.

A missing grant fails before any policy runs. That failure is 42501. Adding a policy does not create a grant, and adding a grant does not write a policy.

The publishable key in your frontend (sb_publishable_..., or the legacy anon key) is meant to be public. Anyone can read it from your shipped app. What a signed-out visitor can reach is whatever you granted to anon, filtered by RLS. The secret key (and the legacy service_role key) bypasses RLS and must stay on a server you control.

Check whether your project still auto-grants new tables

Run this query in the SQL Editor. It is the check from Supabase's Data API guide:

select
  case d.defaclobjtype
    when 'r' then 'tables'
    when 'S' then 'sequences'
    when 'f' then 'functions'
  end as object_type,
  a.grantee::regrole as role,
  string_agg(a.privilege_type, ', ' order by a.privilege_type) as privileges
from pg_default_acl d
cross join lateral aclexplode(d.defaclacl) a
where d.defaclrole = 'postgres'::regrole
  and d.defaclnamespace = 'public'::regnamespace
  and a.grantee in ('anon'::regrole, 'authenticated'::regrole, 'service_role'::regrole)
group by 1, 2
order by 1, 2;

No rows means new objects in public grant nothing to the Data API roles until you grant access yourself (the new default). Rows with select / insert / update / delete for anon or authenticated mean a new public table is still auto-exposed, unless you change the default.

The same default is controlled by Automatically expose new tables in Data API settings.

If you get 42501 on a new table

PostgREST returns a hint with the missing privilege and the role, for example:

{
  "code": "42501",
  "message": "permission denied for table your_table",
  "hint": "Grant the required privileges to the current role with: GRANT SELECT ON public.your_table TO anon;"
}

The hint is accurate about the missing grant. It is not a suggestion to grant every privilege to every role. Grant only what each role should be able to do. Supabase's example treats three steps as one unit:

grant select on public.your_table to anon;
grant select, insert, update, delete on public.your_table to authenticated;
grant select, insert, update, delete on public.your_table to service_role;

alter table public.your_table enable row level security;

create policy "users can read their own rows"
  on public.your_table
  for select
  to authenticated
  using (auth.uid() = user_id);

Copy this only if it matches your app. If signed-out visitors should not read the table, do not grant select to anon. If signed-in users should only read their own rows, do not add a policy to anon using (true).

42501 can also come from a custom schema, column-level privileges, or an INSERT/UPDATE that RLS does not allow. If a grant is already present, use Supabase's 42501 troubleshooting note before widening privileges.

If an AI tool creates your tables, have it emit the GRANT, ENABLE ROW LEVEL SECURITY, and policy statements in the same migration. Supabase publishes an agent skill that includes the grants step.

The part that did not change: your existing tables

Default-privilege changes apply only to new objects. A project can be on the new default for tables you create tomorrow, and still expose tables you created last month.

Two official warnings matter here:

  • A table in an exposed schema without RLS is readable and writable by any role that has a grant on it. Tables created in the Dashboard get RLS enabled by default. Tables created in the SQL Editor, a migration, or another tool do not, until you enable it yourself.
  • A policy such as to anon using (true) lets every signed-out visitor read every row that the anon grant already reaches. Use that shape only for data that is meant to be public.

Once RLS is enabled, a publishable key cannot read rows until you create a policy that allows it. Enabling RLS with no policy is a closed default. Enabling RLS and writing using (true) for anon is an open default. The difference is the policy, not the fact that RLS is on.

A short review of your own app

Stay inside your project. Do not point these checks at someone else's URL.

1. List current grants on public tables:

select table_schema, table_name, grantee, privilege_type
from information_schema.role_table_grants
where table_schema = 'public'
  and grantee in ('anon', 'authenticated', 'service_role')
order by table_name, grantee, privilege_type;

Pay attention to anon plus SELECT, and to write privileges that should not be public.

2. Open Database → Policies. For each Data API table, confirm RLS is on, then read the policies. Can a signed-out visitor read or write rows? Can any signed-in user see every row, or only their own?

3. Optional: call your own table while signed out. Use your project URL and publishable key (or legacy anon key), with no user session. Official docs put publishable keys on the apikey header:

curl "https://YOUR_PROJECT.supabase.co/rest/v1/YOUR_TABLE?select=*&limit=1" \
  -H "apikey: YOUR_PUBLISHABLE_OR_ANON_KEY"

If rows come back that should not be public, tighten the anon grant, the RLS policy, or both. 42501 means a missing grant. An empty array can mean no policy allows those rows, or the table is empty. Do not put a secret or service_role key in this request, or in frontend code. That role bypasses RLS.

If a table should not be on the Data API at all, revoke the client grants. Existing access does not disappear on its own:

revoke all on table public.your_table from anon, authenticated;

Leave service_role if your server still needs it.

If you want a second look at a public app URL, Cheqvo offers a free scan at cheqvo.com/?ref=devto. It is a starting point for your own review, not a substitute for the checks above.

Sources

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.