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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

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
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
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

We're in Beta

About us Mission Statement