Open diogomrts opened 5 months ago
I just encountered an issue that I'm not sure is related to this when adding a new POST route pointing to a generic ation. In this generic action with a required string argument:
action :submit do
argument :contact_name, :string, allow_nil?: false
run fn %Ash.ActionInput{} = input, context ->
dbg("action")
end
end
If we pass an empty string in the body of the POST request it will throw this error:
16:13:26.240 [error] ** (Ash.Error.Invalid)
Invalid Error
* argument contact_name is required
(ash 3.4.41) lib/ash/error/changes/required.ex:4: Ash.Error.Changes.Required.exception/1
(ash 3.4.41) lib/ash/action_input.ex:158: anonymous fn/2 in Ash.ActionInput.require_arguments/1
(elixir 1.17.3) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
Which results in this same error as described above:
{
"errors": [
{
"code": "required",
"id": "4ec324c9-ab23-464d-aa02-018396a7c301",
"meta": {},
"status": "400",
"title": "Required",
"detail": "is required"
}
],
"jsonapi": {
"version": "1.0"
}
}
Setting the request field to null in the json body results in a proper error message:
Really need to get around to this one. Sorry its been so long :)
Describe the bug When I try to setup AshJsonApi with a generic action, if there are required arguments it returns an error but without the field name:
To Reproduce With a simple Ash.Resource and a route like this:
Expected behavior The field seems to be missing because the error structure is like this:
but the implementation for the error is looking for error.vars and not error.field