mautrix / signal

A Matrix-Signal puppeting bridge
GNU Affero General Public License v3.0
499 stars 75 forks source link

Migration does not clean up portals without users properly #425

Closed verymilan closed 7 months ago

verymilan commented 8 months ago

matrix discussion a / matrix discussion b

Right now, coming from the latest release to the rewrite on the latest commit, the migration process fails with the following error:

{"level":"fatal","error":"failed to run upgrade #15: pq: null value in column \"receiver\" of relation \"portal\" violates not-null constraint","db_section":"main","pq_error":{"severity":"ERROR","code":"not_null_violation","detail":"Failing row contains (b8c23d3a-85ca-443d-b275-6bcf0cd8009f, null, null, +49 176 redacted (Signal), null, f, null, null, f, f, 0, null, null).","schema":"public","table":"portal","column":"receiver","file":"execMain.c","line":"1968","routine":"ExecConstraints"},"time":"2024-01-18T20:35:46.541347008Z","message":"Failed to initialize database"}

While the portal row looks like

               chat_id                |   receiver    | mxid |           name            | topic | encrypted | avatar_hash | avatar_url | name_set | avatar_set | revision | expiration_time | relay_user_id
--------------------------------------+---------------+------+---------------------------+-------+-----------+-------------+------------+----------+------------+----------+-----------------+---------------
 b8c23d3a-85ca-443d-b275-6bcf0cd8009f | +49175redacted |      | +49 176 redacted (Signal) |       | f         |             |            | f        | f          |        0 |                 |
(1 row)

and SELECT * FROM "user" WHERE username='+49175redacted' returns 0 rows.

When deleting that row above, it just jumps to the next unwelcome row.