Fix guide · updated 2026-11-16
Supabase "operator does not exist: uuid = text" (42883)
ERROR: operator does not exist: uuid = text. HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
A migration, a policy you create in the SQL Editor, or a supabase.rpc() call fails with operator does not exist: uuid = text (code 42883), and the hint "You might need to add explicit type casts". Somewhere a uuid is compared with text, and Postgres won't compare two different types for you. We reproduced each case on Postgres 16, with the same types as Supabase's auth.uid() and auth.jwt(), and behind Supabase's Data API (PostgREST 13), November 2026. In every case, one side was text: a user_id column created as text, auth.jwt() ->> 'sub', or a function parameter declared as text.
What the error means
auth.uid() returns a uuid, like the ids in auth.users and the columns that store them. auth.jwt() ->> 'sub' returns the same id as text. Postgres has no = between uuid and text. In our test:
- a policy
using (auth.uid() = user_id)on a textuser_idwas refused when we created it: "uuid = text", - a policy
using (auth.jwt() ->> 'sub' = id)on a uuididwas refused with "text = uuid": the order follows your expression, - a view joining
profiles.id = notes.user_id, uuid with text, wasn't created, - a function comparing a text parameter with a uuid column was created fine, then failed each time it was called.
The one-minute check
In the SQL Editor, list the types of your id columns:
select table_name, column_name, data_type from information_schema.columns
where table_schema = 'public' and (column_name = 'id' or column_name like '%\_id')
order by table_name, column_name;
A user_id (or owner_id, author_id) that says text while the ids it holds are uuids is the usual suspect.
Fix 1: make the column a uuid
The lasting fix. Changing the type failed at first in our test, with "cannot alter type of a column used in a policy definition": drop the policies that use the column, change it, then create them again:
drop policy "own notes" on public.notes;
alter table public.notes alter column user_id type uuid using user_id::uuid;
create policy "own notes" on public.notes for select
using ((select auth.uid()) = user_id);
The alter fails if a row holds something that isn't a uuid. Find those rows first:
select user_id from public.notes where user_id !~ '^[0-9a-fA-F-]{36}$';
While you're at it, a foreign key to auth.users (id) keeps the column honest. Choose its delete rule first: Supabase "Database error deleting user" explains why.
Fix 2: cast the other side
If you can't change the column yet, cast the uuid to text, which our test accepted:
create policy "own notes" on public.notes for select
using ((select auth.uid())::text = user_id);
Cast auth.uid(), not the column. user_id::uuid breaks the whole query as soon as one row holds something that isn't a uuid, and a cast on the column also keeps Postgres from using an index on it.
For auth.jwt() ->> 'sub' compared with a uuid column, use auth.uid() instead: it's the same user id, already a uuid. For a join, cast on the text side, p.id::text = n.user_id, until the column is fixed.
A function called with rpc(): declare the parameter uuid
A PL/pgSQL function that compares a text parameter with a uuid column is created without complaint and fails when it runs. In our test, rpc() on such a function answered HTTP 404, with "code":"42883" and this message. The function exists: the Data API reports error 42883 as a 404. Declaring the parameter as uuid fixed it (200):
create function public.note_count(p_user uuid) returns bigint ...
Changing a parameter's type creates a second function next to the old one, so drop the old one: drop function public.note_count(text);.
"operator does not exist: text ->> unknown"
Same error code, other cause: ->> used on a text column that holds JSON. In our test, meta ->> 'color' on a text column failed this way. ->> works on json and jsonb: change the column to jsonb (alter table public.notes alter column meta type jsonb using meta::jsonb;), or cast in the query, meta::jsonb ->> 'color'.
If an AI tool built your app
Give your AI tool this prompt:
Our Supabase database fails with operator does not exist: uuid = text (42883). Find every column that stores a user id or another uuid id but is typed text, and write a migration that changes it to uuid: check first that every value is a valid uuid, and drop and recreate the policies that use the column. In policies, compare (select auth.uid()) with uuid columns. Declare function parameters that hold ids as uuid, and drop the old text versions. Show me the SQL before running it. Don't change anything else.
Not quite your error?
- "invalid input syntax for type uuid": a value isn't a uuid at all: Supabase invalid input syntax for type uuid: "undefined" (22P02).
- "column reference … is ambiguous" in a function: Supabase: column reference "id" is ambiguous (42702).
rpc()answers 404 withPGRST202: then the function really isn't found: Supabase "Could not find the function in the schema cache" (PGRST202).
Still stuck?
Look under the error for the LINE marker: the caret (^) points at the comparison. The two words around the = in the message are the two types, left and right. Change the side that isn't what you meant.
Other Supabase problems? See Supabase fixes.