22P02 uuid 🐘 PostgreSQL

ERROR: invalid input syntax for type uuid: "x"

A value that isn’t a valid UUID was compared with or inserted into a uuid column.

Seen on: PostgreSQL

Meaning

Route parameters like "me", "new" or "undefined", or integer ids passed to uuid columns.

Common causes

  • Non-UUID route parameters
  • "undefined" from the client
  • Mixing integer ids and uuid columns

⚡ Quick fix

  1. Validate the UUID format before querying and return 404/400
  2. Order routes so /items/new isn’t treated as an id

Detailed fix by platform

PostgreSQL

  1. SELECT * FROM items WHERE id = $1::uuid; -- after validating $1 in the app

How to diagnose

  1. Value — What string?
  2. Route — Which route matched?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.