PostgreSQL error: value too long for type character varying

ERROR:  value too long for type character varying(50)

A string exceeded the declared length limit of its column, and PostgreSQL rejected the write rather than silently truncating it. Annoyingly, the message names the type but not the column — finding which column is step one.

What this error means

Two PostgreSQL-specific facts frame the fix:

Common causes

How to diagnose it

-- Quali colonne varchar(50) ha la tabella sospetta:
SELECT column_name, character_maximum_length
FROM information_schema.columns
WHERE table_name = 'users' AND character_maximum_length IS NOT NULL;

Then compare against the payload that failed. If the statement is logged, the values are right there.

How to fix it