Ash FrameworkAF
Ash Framework3y ago
7 replies
Jason

(CaseClauseError) no case clause matching: #Ash.Changeset<api

This must be a very basic question but I'm getting the above error in running this code. add_user_timezone is defined in user.ex which is listed in MyApp.Accounts.Registry. What am I missing?

     current_user
      |> Ash.Changeset.for_update(:add_user_timezone, %{
        browser_timezone: get_connect_params(socket)["timezone"]
      })
      |> Accounts.update!()


<Full error message>
** (CaseClauseError) no case clause matching: #Ash.Changeset<api: MyApp.Accounts, action_type: :update, action: :add_user_timezone, attributes: %{}, relationships: %{}, arguments: %{browser_timezone: nil}, errors: [], data: #MyApp.Accounts.User<...
 first_name: nil, last_name: nil, user_photo_url: nil, user_timezone: nil, inserted_at: ~U[2023-02-16 05:40:59.959000Z], updated_at: ~U[2023-02-16 05:40:59.959000Z], aggregates: %{}, calculations: %{}, __order__: nil, ...>, context: %{actor: nil, authorize?: false}, valid?: true>


<:add_user_timezone>
    update :add_user_timezone do
      accept [:user_timezone]

      argument :browser_timezone, :string do
        allow_nil? true
      end

      manual fn changeset, %{actor: actor} ->
        case Ash.Changeset.get_argument(changeset, :browser_timezone) do
          nil ->
            changeset

          browser_timezone ->
            Ash.Changeset.force_change_attribute(changeset, :user_timezone, browser_timezone)
        end
      end

  code_interface do
    define_for MyApp.Accounts

    define :add_user_timezone, args: [:brower_timezone]
  end
Was this page helpful?