Protocol.UndefinedError: protocol Jason.Encoder not implemented for %Plug.Conn.Unfetched{aspect: :body_params} of type Plug.Conn.Unfetched (a struct), Jason.Encoder protocol must always be explicitly implemented.
If you own the struct, you can derive the implementation specifying which fields should be encoded to JSON:
@derive {Jason.Encoder, only: [....]}
defstruct ...
It is also possible to encode all fields, although this should be used carefully to avoid accidentally leaking private information when new fields are added:
@derive Jason.Encoder
defstruct ...
Finally, if you don't own the struct you want to encode to JSON, you may use Protocol.derive/3 placed outside of any module:
Protocol.derive(Jason.Encoder, NameOfTheStruct, only: [...])
Protocol.derive(Jason.Encoder, NameOfTheStruct)
. This protocol is implemented for the following type(s): Any, Atom, BitString, Date, DateTime, Decimal, Ecto.Association.NotLoaded, Ecto.Schema.Metadata, Float, Integer, Jason.Fragment, Jason.OrderedObject, Lightning.RedactedMap, List, Map, NaiveDateTime, Time
File "lib/jason.ex", line 213, in Jason.encode_to_iodata!/2
File "/app/deps/postgrex/lib/postgrex/type_module.ex", line 947, in Lightning.PostgrexTypes.encode_params/3
File "lib/postgrex/query.ex", line 75, in DBConnection.Query.Postgrex.Query.encode/3
File "lib/db_connection.ex", line 1403, in DBConnection.encode/5
File "lib/db_connection.ex", line 1503, in DBConnection.run_prepare_execute/5
...
(3 additional frame(s) were not displayed)
Sentry Issue: LIGHTNING-6Z