error with keyset pagination and random sort

As the title says i’m trying to define an action that should list my posts in a random sort while using the keyset pagination. This is the action that im calling

read :list do
  ...
  transaction? true

  prepare fn query, context ->
    Ash.Query.before_action(query, fn query ->
      OnmyjobsApp.Repo.query!("select setseed(#{0.42})")
      query
    end)
  end

  prepare before_action(&list_preparation/1)
  prepare build(sort: [Ash.Sort.expr_sort(fragment("RANDOM()"))])
  pagination keyset?: true, required?: true, countable: :by_default, default_limit: 10
end

I know that the problem is not the list_preparation that i’m calling.
The following problem is when i put the last two rows together.

10:24:47.942 [error] Task #PID<0.6631.0> started from #PID<0.6616.0> terminating
** (Ash.Error.Unknown) Unknown Error

Context: resolving data on fetch MyApp.Post.list
* Context: resolving data on fetch MyApp.Post.list

** (UndefinedFunctionError) function nil.cast_in_query?/1 is undefined
  nil.cast_in_query?([])
  (elixir 1.15.0) lib/enum.ex:2585: anonymous fn/3 in Enum.reject/2
  (stdlib 5.0) maps.erl:416: :maps.fold_1/4
  (elixir 1.15.0) lib/enum.ex:2522: Enum.reject/2
  (ash 2.17.20) lib/ash/actions/helpers.ex:391: Ash.Actions.Helpers.load_runtime_types/3
  (ash 2.17.20) lib/ash/actions/read/read.ex:1486: anonymous fn/4 in Ash.Actions.Read.data_field/3
  (ash 2.17.20) lib/ash/engine/request.ex:1140: Ash.Engine.Request.do_try_resolve_local/4
  (ash 2.17.20) lib/ash/engine/request.ex:284: Ash.Engine.Request.do_next/1
  (ash 2.17.20) lib/ash/engine/request.ex:213: Ash.Engine.Request.next/1
  (ash 2.17.20) lib/ash/engine/engine.ex:712: Ash.Engine.advance_request/2
  (ash 2.17.20) lib/ash/engine/engine.ex:637: Ash.Engine.fully_advance_request/2
  (ash 2.17.20) lib/ash/engine/engine.ex:578: Ash.Engine.do_run_iteration/2
  (elixir 1.15.0) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash 2.17.20) lib/ash/engine/engine.ex:307: Ash.Engine.run_to_completion/1
  (ash 2.17.20) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2
  (ash 2.17.20) lib/ash/engine/engine.ex:114: anonymous fn/3 in Ash.Engine.run/2
  (ash 2.17.20) lib/ash/data_layer/data_layer.ex:378: Ash.DataLayer.transaction/4
  (ash 2.17.20) lib/ash/data_layer/data_layer.ex:363: anonymous fn/5 in Ash.DataLayer.transaction/4
  (ash 2.17.20) lib/ash/data_layer/data_layer.ex:378: Ash.DataLayer.transaction/4
  (ash 2.17.20) lib/ash/data_layer/data_layer.ex:363: anonymous fn/5 in Ash.DataLayer.transaction/4

This will be fixed in an upcoming release, but you will need to specify a type to workaround it in the meantime.

  prepare build(sort: [Ash.Sort.expr_sort(fragment("RANDOM()"), :decimal)])