Code in release don't match function empty case

Hello, in my code, I have this function:

  defp get_last_datetime([]), do: {[], nil}

  defp get_last_datetime(exams) do
    last_datetime = Enum.max_by(exams, &Date.to_erl(&1.created_date)).created_date

    {exams, last_datetime}

The first should match when the exams list is empty, testing it directly from iex, it does match correctly.

For some reason, in my release version, it is not matching, this is the error I’m getting:

15:55:52.697 [error] Task #PID<0.2492.0> started from #PID<0.2362.0> terminating
** (Enum.EmptyError) empty error
    (elixir) lib/enum.ex:1520: anonymous fn/0 in Enum.max_by/2
    (external_database) lib/external_database/fetcher/exam.ex:95: ExternalDatabase.Fetcher.Exam.get_last_datetime/1
    (external_database) lib/external_database/fetcher/exam.ex:29: ExternalDatabase.Fetcher.Exam.filter_and_add!/1
    (external_database) lib/external_database/fetcher.ex:123: ExternalDatabase.Fetcher.query_and_add!/1
    (external_database) lib/external_database/fetcher.ex:49: ExternalDatabase.Fetcher.fetch_delta_data!/1
    (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<21.126501267/0 in :erl_eval.expr/5>
    Args: []

I don’t get it, why did it not match the first case?

Can you IO.inspect(exams) ? It could be an Enumerable that is not a list.

Thanks! Indeed that was the case, i was receiving a flow struct instead of the array.