# Postgres error 23502: null value in column "x" of relation "y" violates not-null constraint

> An INSERT or UPDATE left a NOT NULL column empty.

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

SQLSTATE class: Integrity Constraint Violation. Over PostgREST/supabase-js this maps to HTTP 400.

## Causes

- The app did not send the column and it has no default.
- An UPDATE set it to null explicitly.
- A column added with NOT NULL but no default, then inserts from old code paths.

## Fixes

- Send the value, or give the column a default (alter table ... alter column ... set default ...).
- For ownership columns use a default such as auth.uid() so clients cannot forget it.

## Example

```sql
alter table todos alter column user_id set default auth.uid();
```