Diagnostic Queries
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).
- The value is not a member of the enum.
- Enum labels are case-sensitive and exact.
- Common after adding a new state in code but not in the enum.
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
- A label that was never defined on the enum.
- Wrong case or spelling of a label.
- Application adding a new status not yet present in the enum type.
How to fix it
- Add the label:
ALTER TYPE order_status ADD VALUE 'shipped';. - Use an existing label with exact spelling/case.
- List labels:
SELECT enum_range(NULL::order_status);.
Related & next steps
Reference: PostgreSQL 18 Section 8.7 “Enumerated Types”.
Thanks — noted. This helps keep the database accurate.