rgraff
Setting path on an error
I have a validation based on use Ash.Resource.Validation that when invalid returns
{:error,
InvalidAttribute.exception(
field: :variant_key,
path: [:feature_override],
message: "feature variant not found"
)}
The graphql response is missing the path
%{"data" => %{"addFeatureOverrideToAccount" => %{"errors" => [%{"code" => "invalid_attribute", "fields" => ["variant_key"], "message" => "feature variant not found"}], "result" => nil}}}
I expect the path to be ["feature_override","variant_key"]
I’m seeing the same issue in liveview with the error not getting rendered in forms.
Most Liked
rgraff
I’ll do a PR for an ash_phoenix test to reproduce this. ![]()
For ash_graphql, it’s less of an issue for me right now and I’m not sure what the conventions/specs are for errors. I personally would expect a path with camelCase.
Last Post!
Neophen
@rgraff did you manage to solve it? As i’m running into an issue where using the AshPhoenix form i’m not getting the error for a path, doing an inspect like so:
form = AshPhoenix.Form.validate(socket.assigns.form, edition_params)
IO.inspect(form, label: "____form")
the source.source.errors does contain both errors
errors: [
%Ash.Error.Changes.InvalidAttribute{
field: :en,
message: "length must be greater than or equal to %{min}",
private_vars: nil,
value: %{"_unused_lt" => "", "en" => "a", "lt" => ""},
splode: nil,
bread_crumbs: [],
vars: [min: 2],
path: [:title],
stacktrace: #Splode.Stacktrace<>,
class: :invalid
},
%Ash.Error.Changes.InvalidAttribute{
field: :content_types,
message: "must have %{min} or more items",
private_vars: nil,
value: [],
splode: nil,
bread_crumbs: [],
vars: [min: 1],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :invalid
}
],
but the actual errors doesn’t contain the title.en error:
errors: [content_types: {"must have %{min} or more items", [min: 1]}],
This is a custom ash type based on map. here’s a post with more details:
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









