rgraff

rgraff

Ash Core Team

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

rgraff

Ash Core Team

I’ll do a PR for an ash_phoenix test to reproduce this. :pray:

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

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:

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement