23503
what this Postgres error means
How it shows up
insert or update on table "<table>" violates foreign key constraint "<constraint_name>"
What it means
SQLSTATE 23503 is foreign_key_violation: the row points at a row in another table that does not exist, or a delete would leave other rows pointing at nothing.
The usual cause in an AI-built app
AI-built apps often insert a row with a user_id or parent id before the row it points to exists, for example saving a post for a user whose profile row was never created.
Check this first
Take the id value your insert sends for the foreign key column and check that a row with that exact id exists in the table the constraint points to.