fix: check changeset.action before raising a required primary action error

This commit is contained in:
Zach Daniel 2024-09-06 17:02:45 -04:00
parent 44c0d09e30
commit a97a65f6a6
2 changed files with 4 additions and 2 deletions

View file

@ -2178,7 +2178,7 @@ defmodule Ash do
is_nil(changeset.__validated_for_action__) ->
action =
opts[:action] ||
opts[:action] || changeset.action ||
Ash.Resource.Info.primary_action!(changeset.resource, :create).name
Ash.Changeset.for_create(changeset, action, params, opts)

View file

@ -1756,6 +1756,8 @@ defmodule Ash.Changeset do
raise_no_action(changeset.resource, action_or_name, changeset.action_type)
end
else
action = get_action_entity(changeset.resource, action_or_name)
{changeset, _opts} =
Ash.Actions.Helpers.set_context_and_get_opts(
domain,
@ -1763,7 +1765,7 @@ defmodule Ash.Changeset do
opts
)
changeset
%{changeset | action: action}
end
end