Ash Framework Book - how to debug the actions

:wave: I might need to see how what your code looks like up to this point to say for sure. I believe there is a step in the book that addresses that.

To answer your question more directly, there are a few things you can do to debug an action/form.

With the form

With a form that has been returned in the {:error, form} case of AshPhoenix.Form, you can do

AshPhoenix.Form.errors(form, for_path: :all) |> IO.inspect()

Not all errors are displayed in the form automatically because they may not tie to fields that are editable in the form itself. We also log a warning (IIRC that is the level) when we encounter an error that could not be displayed to the user due to not implementing the AshPhoenix.FormData.Error protocol (a safety measure to avoid displaying internal details to the user.

You can also peek at form.source (or form.source.source, if you have a %Phoenix.Form{}

in the action itself

change fn changeset, _ -> 
  Ash.Changeset.after_transaction(changeset, fn result -> 
    IO.inspect(result)
    result
  end)
end

You can add a hook like this to display the ok/error result from the action.

You’ll want to make sure that your action is not accepting previous_names as an input, and that your change is being run in all necessary places to set the attribute, that it has a default of [] etc.