No such input `xxx` for action

This read action is giving me the above error message, after migration to Ash 3.0. If it’s relevant, key is the source and destination attribute name for Resource1’s belongs_to relationship.

key = "1234"
Resource1.read_by_key!(key)

Resource1


actions do
    default_accept :*
    read :read_by_key do
      argument :key, :string

      filter expr(key == ^arg(:key))
    end
...

code_interface do
    domain ...
    define :read_by_key, action: :read, args: [:key]

...

Should it be action: :read_by_key?

1 Like

That works. Thank you! I misunderstood action: is to specify the type of action (:read, :create, etc.) rather than the name of specific function.

The doc says action: defaults to the same name as the function which led me to think

define :read_by_key, args: [:key] should work

instead of

define :read_by_key, action: :read_by_key, args: [:key]

But it doesn’t because action: is not optional. What does the Doc mean about the default here?

Name:  action
Type:  atom
Docs: The name of the action that will be called. Defaults to the same name as the function.

I’m 99% sure that action is optional. What makes you say that it’s not optional? Do you get a required error if you don’t specify it?

Never mind. There was a typo. :frowning: