Non-UTF8 user nicknames crash API request #1055

Closed
opened 2026-01-24 12:39:38 +00:00 by Oneric · 0 comments
Owner

Your setup

From source

Extra details

Alpine 3.23

Version

basically 816d2332a

PostgreSQL version

18

What’s wrong?

We previously got a report about such crashes inside the flake library in https://meta.akkoma.dev/t/frontend-unicodeconversionerror/847 and fixed this via 936be4edbb.

However, it seems this can still crash a bit later inside the db query since postgres expects the text field to be valid UTF-8 too:

Request: GET /%c0
** (exit) an exception was raised:
    ** (Cachex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0xc0
        (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1098: Ecto.Adapters.SQL.raise_sql_call_error/1
        (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:996: Ecto.Adapters.SQL.execute/6
        (ecto 3.13.4) lib/ecto/repo/queryable.ex:241: Ecto.Repo.Queryable.execute/4
        (ecto 3.13.4) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
        (ecto 3.13.4) lib/ecto/repo/queryable.ex:163: Ecto.Repo.Queryable.one/3
        (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1245: Pleroma.User.get_by_nickname/1
        (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1260: Pleroma.User.get_or_fetch_by_nickname/1
        (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1218: anonymous fn/2 in Pleroma.User.get_cached_by_nickname/1

(notably this is the exact same request path as originally reported in the forum)

Making non-UTF8 names work would require changing the thype of the nickname to be an arbitrary binary, but I don’t think this is desirable. Instead just making it gracefully 404 would be good.

This affects all endpoints accepting nicknames, but also only if they are actually used with nicknames (as akkoma-fe does, accepting nicknames in addition to IDs in several endpoints is a Pleroma extension). Likely not causing much actual issues in practice though since all existing users the frontend might proactively fetch on its own are guaranteed to have valid UTF-8 names

Severity

I can manage

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details Alpine 3.23 ### Version basically 816d2332a ### PostgreSQL version 18 ### What’s wrong? We previously got a report about such crashes inside the flake library in https://meta.akkoma.dev/t/frontend-unicodeconversionerror/847 and fixed this via 936be4edbb2dda1816424767cb9f316a937b2d27. However, it seems this can still crash a bit later inside the db query since postgres expects the `text` field to be valid UTF-8 too: ``` Request: GET /%c0 ** (exit) an exception was raised: ** (Cachex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0xc0 (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1098: Ecto.Adapters.SQL.raise_sql_call_error/1 (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:996: Ecto.Adapters.SQL.execute/6 (ecto 3.13.4) lib/ecto/repo/queryable.ex:241: Ecto.Repo.Queryable.execute/4 (ecto 3.13.4) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3 (ecto 3.13.4) lib/ecto/repo/queryable.ex:163: Ecto.Repo.Queryable.one/3 (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1245: Pleroma.User.get_by_nickname/1 (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1260: Pleroma.User.get_or_fetch_by_nickname/1 (pleroma 3.17.0-wf-169-gca7d542f-u816d2332a-trunk) lib/pleroma/user.ex:1218: anonymous fn/2 in Pleroma.User.get_cached_by_nickname/1 ``` (notably this is the exact same request path as originally reported in the forum) Making non-UTF8 names work would require changing the thype of the nickname to be an arbitrary binary, but I don’t think this is desirable. Instead just making it gracefully 404 would be good. This affects all endpoints accepting nicknames, but also only if they are actually used with nicknames *(as akkoma-fe does, accepting nicknames in addition to IDs in several endpoints is a Pleroma extension)*. Likely not causing much actual issues in practice though since all existing users the frontend might proactively fetch on its own are guaranteed to have valid UTF-8 names ### Severity I can manage ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
Oneric changed title from Non-UTF8 usernames crash connection process to Non-UTF8 user nicknames crash API request 2026-01-24 12:46:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AkkomaGang/akkoma#1055
No description provided.