:erlang.term_to_binary and postgresql => invalid byte sequence for encoding "UTF8"

Thanks for chiming in @jhogberg and @kip!

This was interesting to solve.

The DB is set to UTF8:
2023-11-22 08_41_28-sudo -Hiu postgres psql

While I was trying to narrow down the problem I got a different error message:

09:44:01.258 [error] GenServer #PID<0.7186.0> terminating
** (Postgrex.Error) ERROR 22023 (invalid_parameter_value) payload string too long
    (ecto_sql 3.11.0) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1

Which leads to the real problem
The table has a trigger attached - and that trigger is converting the updated/inserted table row to JSON to send a message using pg_notify => trying to convert the binary data…

And I was able to verify it as soon as I had a look at the postgresql log files

Never thought of this :crazy_face: