Category: Supabase and databases

PostgreSQL: 22P02 invalid input syntax for type uuid

Read this guide in Polish

The API returns SQLSTATE 22P02 when the filter or INSERT has received text that is not a valid UUID. The uuid column requires the correct identifier format, and the frontend can send an empty string or undefined text.

How to determine the source of the error

Save the value type sent to the endpoint and check that the route parameter really contains ID.

Verify that the form does not replace the missing UUID with an empty string instead of null.

What to do step by step

1. Add server side ID validation before calling the database and distinguish the lack of ID from the wrong format.

2 . Do not use projecting all values into text; move the identifier from the corresponding record field.

How to check the score

Invalid ID gives controlled 400 and the correct goes to the correct query.

What to do

Do not construct SQL filters by concatenationing an unverified parameter with URL.