Supabase: Could not find the column in the schema cache
Could not find the 'role' column of 'profiles' in the schema cache (PGRST204, HTTP 400) means the object you passed to insert, update or upsert has a key that isn't a column of that table, or is a column PostgREST hasn't loaded yet. Fix the key, strip fields the table doesn't have, or run notify pgrst, 'reload schema'; after adding a column. Before adding the column the client sent, check what it is: a role, plan or is_admin column on a table users can update is a self-promotion button.
PostgREST, the API behind supabase.from(), checks the keys of your JSON body against its cached list of the table's columns before it writes anything. One unknown key fails the whole request.
What does "Could not find the column of in the schema cache" mean?
It's PostgREST's column-not-found error. In Error.hs it has code PGRST204, status 400, and the message template Could not find the '<column>' column of '<table>' in the schema cache:
const { error } = await supabase
.from("profiles")
.update({ display_name: "Ada", role: "admin" })
.eq("id", user.id);
// error.code === "PGRST204"
// error.message === "Could not find the 'role' column of 'profiles' in the schema cache"
It only comes from write payloads. A bad column in select() or a filter like .eq("rol", ...) is a different error, Postgres's 42703 column ... does not exist. If you see PGRST204, look at the object you're sending, not the query around it.
The causes, in the order to check them
1. A typo or a naming mismatch. Snake_case against camelCase is the usual miss: the column is created_at, the JavaScript object says createdAt. Postgres also folds unquoted names to lower case, so create table ... (createdAt timestamptz) makes a column called createdat, and createdAt won't match it. Copy the name from the table editor.
2. The object carries fields the table doesn't have. This is the common one. Typical sources:
- Spreading form state:
update({ ...form })sends every input, includingconfirmPasswordor a UI-only flag. - Writing back a row you read with an embed:
select("*, author:profiles(name)")returns anauthorkey, and passing that row toupdate()fails withCould not find the 'author' column of 'posts'. - Adding computed fields client-side (
fullName,isOwner) and saving the whole object.
3. The column exists, but the cache is stale. You added it a moment ago and PostgREST hasn't reloaded. Supabase normally picks up schema changes on its own. When it doesn't, run this in the SQL Editor:
notify pgrst, 'reload schema';
4. You're writing to the wrong relation. A view that doesn't select the column, a table of the same name in another schema, or a different project in your env file. The table name in the message tells you which relation PostgREST looked at.
How do I fix "Could not find the column of in the schema cache"?
Send only the columns you mean to write. Pick fields explicitly instead of spreading:
const { display_name, avatar_url } = form;
await supabase
.from("profiles")
.update({ display_name, avatar_url })
.eq("id", user.id);
That clears cause 2, including the embed case, makes a typo (cause 1) easy to spot, and it's also the first half of the security fix below. If the column is genuinely new, add it in a migration and reload the cache.
When "just add the column" is the bug
Here's a common fix in a settings page. The form sends role (left over from an admin screen, or generated by an AI tool that assumed one), the update fails with PGRST204, and the fix is to add the column it asked for:
create policy "update own profile" on public.profiles
for update to authenticated using ((select auth.uid()) = id);
-- "Could not find the 'role' column of 'profiles' in the schema cache"
-- fix: add the column the settings form sends
alter table public.profiles add column role text not null default 'member';
- Warningsupabase/migrations/20261124090000_profiles_role.sql:9
Users can update their own role, plan or credits
Limit what users can write: `REVOKE UPDATE ON public.<table> FROM authenticated; GRANT UPDATE (display_name, avatar_url) ON public.<table> TO authenticated;` (list only the columns users should edit). Or add a BEFORE UPDATE trigger that rejects changes to the privileged columns when current_user is authenticated. Better still, keep roles and plans in a table only your server writes.
The error is gone and every user can now make themselves an admin. RLS picks rows, not columns: "update own profile" lets a user change any column of their own row, role included, and any policy that trusts role = 'admin' trusts whatever they typed. One call from the browser console does it:
await supabase.from("profiles").update({ role: "admin" }).eq("id", user.id);
The same goes for plan, credits, is_verified or subscription_status. The PGRST204 error was the one thing stopping it. We've seen this exact shape in a production app: how any VivTrack user could give themselves Pro.
How do I add a privileged column safely?
Put it where users can't write it, or take away their write access to it.
Option 1: a separate table only your server writes. Keep role and plan in public.user_roles or public.subscriptions with a SELECT policy for the owner and no INSERT, UPDATE or DELETE policy. Your server writes it with the secret key after checking whatever grants the role (an invite, a Stripe webhook).
Option 2: column grants. Replace the table-wide UPDATE grant with one for the editable columns only:
revoke update on public.profiles from authenticated;
grant update (display_name, avatar_url) on public.profiles to authenticated;
The table-level revoke is the part people skip. A column-only revoke update (role) does nothing while the table-wide grant exists, as explained in why REVOKE does nothing for column-level security. After the change, an update that includes role fails with 42501 permission denied for table profiles instead of succeeding.
Also check the policy's WITH CHECK. An UPDATE policy with with check (true) lets users move rows to someone else's id as well; the WITH CHECK (true) trap covers it.
The sibling errors
The same PostgREST file produces the other "in the schema cache" errors:
Could not find the table 'public.X' in the schema cache(PGRST205, 404): the table isn't found at all. See Could not find the table in the schema cache.Could not find a relationship between 'X' and 'Y' in the schema cache(PGRST200, 400): an embed with no foreign key behind it. See Could not find a relationship in the schema cache.
Quick self-check
List the table's actual columns:
select column_name, data_type
from information_schema.columns
where table_schema = 'public' and table_name = 'profiles'
order by ordinal_position;
Then check whether signed-in users can update the privileged ones:
select column_name, privilege_type
from information_schema.column_privileges
where table_schema = 'public' and table_name = 'profiles'
and grantee = 'authenticated' and privilege_type = 'UPDATE';
If role, plan or any credit column appears there, and the table has an "update own row" policy, users can set it on themselves. In code, grep for spread writes:
grep -rnE "\.(update|insert|upsert)\(\s*\{?\s*\.\.\." app/ lib/ src/ 2>/dev/null
That catches spreads only. Also review calls that pass a whole fetched row back, like .update(row).
Does GuardLayer catch this?
Yes. The code scan flags an own-row UPDATE policy on a table with columns like role, is_admin, plan or credits when no column grant or BEFORE UPDATE trigger limits them. It reads all your migrations together, so a role column added in a later migration still counts, and a later table-level revoke update clears the finding. Billing columns like plan or credits are always a warning. A role or is_admin column is a warning when another policy or function reads it, and informational until then.
FAQ
What is PGRST204 in Supabase? PostgREST's column-not-found error, returned with HTTP 400 when an insert, update or upsert body has a key that isn't a column of the target table.
Why do I get PGRST204 after adding the column?
PostgREST's schema cache hasn't reloaded yet. Run notify pgrst, 'reload schema'; in the SQL Editor.
Can I make Supabase ignore extra fields? Not through supabase-js. Unknown keys fail the request, so pick the columns you write in code. That also stops a client from writing columns you never meant to expose.
Why does select() with a wrong column give a different error?
Reads go to Postgres as SQL, so a missing column there is Postgres error 42703. PGRST204 is PostgREST checking a write payload before it builds the SQL.
Is it safe to keep a role column on profiles?
Only if users can't write it: a table-level revoke update plus a column grant for the editable fields, or a BEFORE UPDATE trigger that rejects changes to it. Otherwise move it to a table only your server writes.
See which of your Supabase tables anyone can read, free
Connect your Supabase project read-only. GuardLayer checks RLS, policies, grants and functions as they are right now, and gives you the SQL to fix each problem. It never reads your rows and can't change anything.
Check my Supabase projectPrefer to check code instead? Scan your repo, no signup.