Package: ejabberd
Version: 24.12-3+deb13u2
Severity: normal

Dear Maintainer,

mod_matrix_gw (the experimental Matrix federation gateway) is non-functional
in the Trixie package because ejabberd 24.12 is built against Erlang/OTP 27,
whose *native* `json` module cannot encode the EEP-18 / jiffy-style
`{[{Key,Value},...]}` terms that ejabberd's `misc:json_encode_with_kv_lists/1`
passes to it. Every outbound Matrix event therefore crashes and nothing
federates.

Reproduce:
  1. Enable mod_matrix_gw with an ejabberd_http listener on 8448 (/_matrix)
     and an ed25519 signing key.
  2. From a local XMPP account, send a chat to `user%remote.tld@matrix.<vhost>`.
  3. Crash:

  @mod_matrix_gw_room:handle_event/4:583 failed add_event: {error,
     {unsupported_type, {[{<<"auth_events">>,[]}, {<<"content">>, ...},
       ... {<<"type">>,<<"m.room.message">>}]}},
     [{json,do_encode,2,[{file,"json.erl"},{line,201}]},
      {misc,json_encode_with_kv_lists,1,[{file,"misc.erl"},{line,143}]},
      {mod_matrix_gw,content_hash,1,[{file,"mod_matrix_gw.erl"},{line,663}]},
      {mod_matrix_gw_room,add_event,2,...},
      {mod_matrix_gw_room,handle_event,4,...}]}

Confirmed it is the ejabberd+OTP-27 combination, not ejabberd itself:
building/running the same ejabberd config under Erlang/OTP 26 (ProcessOne's
`ejabberd/ecs` container, which bundles OTP 26) works correctly -- an
XMPP->Matrix direct message was delivered end-to-end. On OTP < 27 ejabberd
uses an external JSON library and is unaffected.

Upstream reports:
  - https://github.com/processone/ejabberd/issues/4602 (this issue, with full
    analysis, filed as a follow-up)
  - https://github.com/processone/ejabberd/issues/4244 (closed; same root cause,
    fix appears incomplete for OTP 27 -- also reproduced on 24.12 at
    mod_matrix_gw:sign_json/2, mod_matrix_gw.erl:722)

Possible resolutions for the Debian package:
  - Backport the upstream fix that makes `misc:json_encode_with_kv_lists/1`
    OTP-27-safe (convert wrapped-proplists to maps / use a json encoder
    callback), once available; or
  - Document the limitation for the OTP-27 build.

Non-Matrix functionality is unaffected.

-- System Information:
Debian Release: 13 (trixie)
Architecture: amd64
Kernel: Linux 6.12.88+deb13-cloud-amd64
Locale: LANG=en_US.UTF-8

Versions of packages ejabberd depends on:
ii  erlang-base  1:27.3.4.1+dfsg-1+deb13u2

Reply via email to