invalid input value for enum …: “…”

SQLSTATE 22P02 condition invalid_text_representation class 22 — Data Exception severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.

Symptoms

A value was supplied for an enum type that is not one of the type’s defined labels. PostgreSQL raises SQLSTATE 22P02 (invalid_text_representation).

What the server log shows

ERROR:  invalid input value for enum order_status: "shipped"

Why PostgreSQL raises this — what the manual says

Section 8.7 Enumerated Types:

“Enum labels are case sensitive, so ‘happy’ is not the same as ‘HAPPY’.”

Enum values are constrained to a fixed label set. Input that is not one of those labels has no valid internal representation and is rejected with 22P02.

Common causes

How to fix it

  1. Add the label: ALTER TYPE order_status ADD VALUE 'shipped';.
  2. Use an existing label with exact spelling/case.
  3. List labels: SELECT enum_range(NULL::order_status);.

Related & next steps

Reference: PostgreSQL 18 Section 8.7 “Enumerated Types”.