Fix guide · updated 2026-11-16
Supabase invalid input syntax for type uuid: "undefined" (22P02)
{"code":"22P02","details":null,"hint":null,"message":"invalid input syntax for type uuid: \"undefined\""}
A page of your app loads nothing, and the request behind it failed with invalid input syntax for type uuid: "undefined", code 22P02, HTTP 400. The database received the word "undefined" where it expected an ID: the variable your code put in the filter was empty when the query ran. We ran Supabase's Data API (PostgREST 13) ourselves, with the requests supabase-js builds (version 2.119, November 2026). Here's how to find the empty variable, and how to make the query wait for it.
What the error means
supabase-js writes each filter into the request's address: .eq('user_id', value) becomes user_id=eq. followed by the value as text. JavaScript writes an empty value as the word itself, so the database gets "undefined" or "null" to compare with a uuid column, and refuses. In our test:
.eq('id', undefined)sentid=eq.undefinedand gotinvalid input syntax for type uuid: "undefined",.eq('id', null)sentid=eq.nulland got the same error with"null",.in('id', [undefined, …]),.single(),.update()and.delete()with an undefined ID all got the same error,- an integer column says
invalid input syntax for type integer: "undefined"instead.
Nothing is wrong with your table or your policies. The fix is in the code that runs the query.
The one-minute check
Open your browser's Network tab, reload, and click the failing request (it shows 400). Its address names the table and the column, for example /rest/v1/profiles?select=*&user_id=eq.undefined. Search your code for that table, find the filter on that column, and log the value just before the query:
console.log('user_id filter =', userId) // the variable your .eq() uses
If it prints undefined or null, one of the causes below applies. If it prints something that isn't an ID, see the last one.
1. The user isn't loaded yet
A query filters on user?.id and runs on the first render, before Supabase has loaded the session, so user is still null. Get the user first, and stop if there isn't one:
const { data: { user } } = await supabase.auth.getUser()
if (!user) return // not signed in (yet): don't query
const { data, error } = await supabase.from('profiles').select('*').eq('user_id', user.id)
In React, keep user?.id in the effect's dependencies and return early while it's missing. With React Query, add enabled: !!user?.id so the query waits.
2. A URL parameter with another name, or the word "undefined" in the URL
The route is /projects/:projectId but the page reads useParams().id: that's undefined. Use the same name in both places. Or the link to the page was built while its ID was missing, and the address itself says /projects/undefined: the page then reads the text "undefined", and the query fails the same way. Fix the code that builds the link, and check the parameter before querying:
const { projectId } = useParams()
if (!projectId || projectId === 'undefined') return // show "Not found" instead
3. The ID comes from data that hasn't arrived
A second query uses a field from the first one, like profile?.team_id, and runs before the first one has answered. Run it only once that value exists: in the first query's result, or with enabled: !!profile?.team_id in React Query.
4. The wrong field name
The row has user_id, but the code reads row.userId or row.uuid: a field that doesn't exist is undefined. Log the whole object (console.log(row)) and use the key it really has.
5. null on purpose: use .is()
If you want the rows where a column is empty, .eq('team_id', null) fails with "null". Use .is(), which our test answered normally:
const { data, error } = await supabase.from('profiles').select('*').is('team_id', null)
6. A value that isn't a uuid
If the message quotes something else, like invalid input syntax for type uuid: "123" or a name, the variable isn't empty: it's the wrong value for that column. A number from another table, a slug from the URL, an email address. Filter on the column that holds that value, for example .eq('slug', slug), or look up the row's uuid first.
Don't hide it with .match()
.match({ id: undefined }) doesn't fail: supabase-js drops keys whose value is undefined, so the request goes out with no filter at all. In our test it returned every row of the table. Never switch to .match() to make this error go away, and above all not before .update() or .delete(). Make the query wait for the value instead.
If an AI tool built your app
Give your AI tool this prompt, with the table and column from the Network tab:
A Supabase query on the profiles table fails with invalid input syntax for type uuid: "undefined" because its user_id filter is undefined when it runs. Find every Supabase query whose filter value can be undefined or null at that moment (user?.id, route params, fields from another query). Don't run those queries until the value exists: return early, or use enabled: !!value in React Query. Use .is(column, null) where null is meant. Don't replace .eq() with .match(). Don't change anything else.
Not quite your error?
- An
rpc()call with an undefined argument sends no argument at all, and gets a 404 "Could not find the function … without parameters": Supabase "Could not find the function in the schema cache" (PGRST202). - An
insert()with an undefined value leaves that column out. In our test it then failed withnull value in column "user_id" … violates not-null constraint(23502). If a policy checksuser_id, you may get Supabase RLS: "new row violates row-level security policy" instead. - The ID is right but
.single()finds no row: Supabase 406 and PGRST116: "Cannot coerce the result to a single JSON object". - The user is never loaded, even after waiting: Supabase "Auth session missing!" error.
- The same undefined in a Realtime filter (
filter: `user_id=eq.${user?.id}`) doesn't fail loudly: the channel still saysSUBSCRIBEDand no event ever comes. See Supabase Realtime not working: SUBSCRIBED but no events.
Still stuck?
Look at the failing request's address again: each column=eq.undefined in it is one filter with an empty value, so there may be more than one. Log every variable used in that query's filters on the same line, and reload: the one that prints undefined is the one to wait for.
Other Supabase problems? See Supabase fixes.