Error when using :on_lookup for many_to_many sorted using expr_sort

This is a followup on my previous question, I’ll paste here the relevant part:

   many_to_many :dishes, Dish do
      through DailyMenuDish
      join_relationship :daily_menu_dishes

      sort [Ash.Sort.expr_sort(parent(daily_menu_dishes.position))]

      source_attribute_on_join_resource :daily_menu_id
      destination_attribute_on_join_resource :dish_id
    end

I had this relationship and all was well if I just wanted to create it and display it in order using the position attribute on the join resource (see previous post).

Now I also wanted to update the dishes in the menu (to be precise, I transformed the create to be an upsert) and I’ve found the correct options to do so using manage_relationship but they work only if I comment out the sort option.

If I don’t, it fails with:

* ** (KeyError) key :parent_bindings not found in: %{
  sort: [
    {#Ash.Resource.Calculation.Expression<[expr: parent(daily_menu_dishes.position)]>,
     :asc}
  ],
  context: %{
    private: %{actor: nil, authorize?: false, in_before_action?: true},
    action: %Ash.Resource.Actions.Read{
      arguments: [],
      description: nil,
      filter: nil,
      get_by: [],
      get?: false,
      manual: nil,
      metadata: [],
      modify_query: nil,
      name: :read,
      pagination: false,
      preparations: [],
      primary?: true,
      touches_resources: [],
      transaction?: false,
      type: :read
    },
    actor: nil,
    authorize?: false,
    accessing_from: %{name: :dishes, source: MyApp.MenuManagement.DailyMenu},
    query_opts: [
      verbose?: false,
      actor: nil,
      authorize?: false,
      page: nil,
      return_query?: false
    ],
    initial_limit: 1,
    initial_offset: 0,
    page_opts: nil,
    initial_query: #Ash.Query<
      resource: MyApp.MenuManagement.Dish,
      filter: #Ash.Filter<name == "baz">,
      sort: [
        {#Ash.Resource.Calculation.Expression<[expr: parent(daily_menu_dishes.position)]>,
         :asc}
      ],
      limit: 1
    >,
    filter_requests: []
  },
  bindings: %{
    0 => %{type: :root, path: [], source: MyApp.MenuManagement.Dish}
  },
  resource: MyApp.MenuManagement.Dish,
  current: 1,
  calculations: %{},
  aggregate_defs: %{},
  in_group?: false,
  current_aggregate_name: :aggregate_0,
  aggregate_names: %{},
  parent_resources: []
}    at dishes, 2

    (ash 2.17.3) lib/ash/api/api.ex:2324: Ash.Api.unwrap_or_raise!/3
    iex:41: (file)

I wasn’t sure where to open an issue because on_lookup is from Ash core, while the :parent_binding error comes from Ash Postgres, let me know if it helps if I do it and if I need to provide some more information.