Menu

Supabase 22P02 "invalid input syntax for type uuid": 6 causes and the fixes that do not weaken your security
📰

Supabase 22P02 "invalid input syntax for type uuid": 6 causes and the fixes that do not weaken your security

DEV Community: postgres·ProofForge·3 days ago
#EPo7h5uH
#devtopostgresql#devto#dev#query#undefined
Long article (500 words) — no AI summary yet.
Reading 0:00
15s threshold

Your Supabase query fails with:

{ "code" : "22P02" , "message" : "invalid input syntax for type uuid: \"undefined\"" }

Enter fullscreen mode

Exit fullscreen mode

The value in the message is often the string undefined , null , an empty string, or a number. It tends to appear on a detail page, a dashboard filter or right after login. It looks like a database problem. It is almost always a bug in what your app sent.

What it means

The column is of type uuid , and the value sent in the query is not a valid UUID such as 3f2b8c1e-9a4d-4c7e-b1a2-5d6e7f8a9b0c . Postgres refuses to cast it and returns 22P02 before it even looks at your rows or policies.

The 6 usual causes

The id is not loaded yet. A route param or state variable is still undefined on first render, and the query runs anyway.

The user is not signed in. user.id is undefined , and you filter by user_id .

A numeric id against a uuid column.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.