ERROR: new row for relation "x" violates check constraint "y"

A value failed a CHECK constraint (e.g. price > 0, status IN (…)).

Seen on: PostgreSQL

Meaning

The constraint name tells you which rule failed; DETAIL shows the failing row.

Common causes

  • Value outside allowed range
  • Enum-like CHECK not updated for new values
  • Application validation out of sync

⚡ Quick fix

  1. Validate before writing
  2. Update the CHECK constraint when adding allowed values

Detailed fix by platform

PostgreSQL

  1. \d+ products -- shows CHECK constraints

How to diagnose

  1. Constraint — Which one?
  2. Value — Failing row

🧠 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.