[error] Failure while translating Erlang's logger event

I recently got into this error on my raspberry pi running (rasbian) a phoenix app… I guess there is some kind of version missmatch but I cannot figure it out. Maybe someone knows whats wrong?

It crashes with the following error on every http request:

[error] 3914- fatal: :expected_element_start_tag

[error] Failure while translating Erlang's logger event
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:expected_element_start_tag, {:file, :file_name_unknown}, {:line, 1}, {:col, 2}} of type Tuple. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.PrepareStream, DBConnection.Stream, Timex.Interval, Tortoise.Package.Subscribe, CubDB.Btree, CubDB.Btree.Diff, CubDB.Btree.KeyRange, IO.Stream, HashSet, Function, Date.Range, List, Stream, GenEvent.Stream, Range, MapSet, HashDict, File.Stream, Map
    (elixir 1.10.2) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.10.2) lib/enum.ex:141: Enumerable.reduce/3
    (elixir 1.10.2) lib/enum.ex:3383: Enum.map_intersperse/3
    (elixir 1.10.2) lib/enum.ex:1495: Enum.map_join/3
    (elixir 1.10.2) lib/exception.ex:579: Exception.format_stacktrace/1
    (elixir 1.10.2) lib/exception.ex:145: Exception.format/3
    (plug_cowboy 2.3.0) lib/plug/cowboy/translator.ex:56: Plug.Cowboy.Translator.translate_ranch/6
    (logger 1.10.2) lib/logger/handler.ex:216: Logger.Handler.do_translate/6
    (logger 1.10.2) lib/logger/handler.ex:209: Logger.Handler.translate/6
    (logger 1.10.2) lib/logger/handler.ex:126: Logger.Handler.do_log/4
    (logger 1.10.2) lib/logger/handler.ex:88: Logger.Handler.log/2
    (kernel 6.5) logger_backend.erl:51: :logger_backend.call_handlers/3
    (kernel 6.5) logger_backend.erl:38: :logger_backend.log_allowed/2
    (cowboy 2.8.0) /home/kwando/blog/deps/cowboy/src/cowboy_http.erl:1209: :cowboy_http.commands/3
    (cowboy 2.8.0) /home/kwando/blog/deps/cowboy/src/cowboy_http.erl:257: :cowboy_http.loop/1
    (stdlib 3.10) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
$ elixir --version
Erlang/OTP 22 [erts-10.5.4] [source] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.10.2 (compiled with Erlang/OTP 21)

:arrow_up: maybe “compiled with Erlang/OTP 21” and running on “Erlang/OTP 22” is the problem?

      {:ecto_sql, "~> 3.0"},
      {:phoenix_ecto, "~> 4.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 0.13.3"},
      {:phoenix_pubsub, "~> 2.0"},
      {:phoenix, "~> 1.5.3"},
      {:plug_cowboy, "~> 2.0"},
      {:postgrex, ">= 0.0.0"},
      {:timex, "~> 3.0"},

I tried to compile elixir myself, but still broken with the same error :disappointed:

Erlang/OTP 22 [erts-10.5.4] [source] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.10.4 (compiled with Erlang/OTP 22)

Gonna try downgrading to Erlang/OTP 21 + recompiling elixir… poor little raspberry pi, been compiling stuff all day now

nope… same story.

whenever you were changing versions of erlang/elixir, were you removing the “_build” directory ?

yes, I removed _build and deps. But I’m not sure it is a elixir-issue anymore, that error seems to originate from sweet_xml

thought so but worth checking as often it’s these kind of things…

So this turned out to be an issue with xmerl which just bails out when given bad XML. Apparently it throws an :exit which I can catch and convert to a regular {:error, _} tuple.

I did a bunch of upgrades and suddenly my app started to misbehave… so I chased to wrong rabbit for a while. But I learned some new stuff so I guess its fine :slight_smile:

Internal Server ErrorRequest:<?xml version="1.0" encoding="UTF-8" ?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetStartEndPoint xmlns="http://www.etis.fskab.se/v1.0/ETISws"><FromPoint>kronprinsen</FromPoint><ToPoint>xxxx</ToPoint>    <FromPointType>0</FromPointType><ToPointType>0</ToPointType><MaxResultCount>15</MaxResultCount></GetStartEndPoint></soap:Body></soap:Envelope>