# Postgres error 22001: value too long for type character varying(n)

> A string is longer than the column allows.

Source: https://scribase.com/postgres-errors/22001

SQLSTATE class: Data Exception. Over PostgREST/supabase-js this maps to HTTP 400.

## Causes

- Inserting or updating text longer than a varchar(n) or char(n) limit.
- Multi-byte characters: the limit counts characters, but an upstream system may have counted bytes.

## Fixes

- Validate length in the app before writing, with the same limit as the column.
- If the limit is arbitrary, change the column to text (optionally with a CHECK constraint on length). Changing varchar(n) to text does not rewrite the table.

## Example

```sql
alter table profiles alter column bio type text;
alter table profiles add constraint bio_length check (char_length(bio) <= 2000);
```