mox icon indicating copy to clipboard operation
mox copied to clipboard

Undefined protocol error

Open nikitosing opened this issue 8 months ago • 3 comments

Hello! After updating :mox from 1.1.0 to 1.2.0, we started encountering the following (blinking) errors in our CI tests. Downgrading back to 1.1.0 resolved the issue. Could you please take a look?

  1) test /addresses/{address_hash}/nft/collections test filters (BlockScoutWeb.API.V2.AddressControllerTest)
Error:      test/block_scout_web/controllers/api/v2/address_controller_test.exs:3649
     ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Cldr.Unit.Range, DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, Explorer.BoundQueue, File.Stream, Floki.HTMLTree, Flow, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Postgrex.Stream, Range, Stream, Timex.Interval
     stacktrace:
       (elixir 1.17.3) lib/enum.ex:1: Enumerable.impl_for!/1
       (elixir 1.17.3) lib/enum.ex:166: Enumerable.reduce/3
       (elixir 1.17.3) lib/enum.ex:4423: Enum.reduce/3
       (stdlib 6.1.2) maps.erl:860: :maps.fold_1/4
       (mox 1.2.0) lib/mox.ex:848: Mox.__verify_mock_or_all__/2
       (mox 1.2.0) lib/mox.ex:819: anonymous fn/1 in Mox.verify_on_exit!/1
       (ex_unit 1.17.3) lib/ex_unit/on_exit_handler.ex:136: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit 1.17.3) lib/ex_unit/on_exit_handler.ex:122: ExUnit.OnExitHandler.on_exit_runner_loop/0

nikitosing avatar Jun 05 '25 13:06 nikitosing

Can you reproduce this locally too?

whatyouhide avatar Jun 09 '25 08:06 whatyouhide

No, I couldn't reproduce it locally

nikitosing avatar Jun 09 '25 09:06 nikitosing

This is going to be quite hard to debug without a way to reproduce it somehow. The error is likely coming from expectations not being set correctly within Mox/nimble_ownership, so it might be a bug, but I've never seen it happen so I wouldn't really know where to start 😄

whatyouhide avatar Jun 11 '25 08:06 whatyouhide