rgraff

rgraff

Ash Core Team

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.

First Post!

zachdaniel

zachdaniel

Creator of Ash

Can you try this:

{:error,
  InvalidAttribute.exception(
    field: :variant_key,
    message: "feature variant not found"
   ) |> Ash.Error.set_path([:feature_override])}

We should make the path key work for all exceptions by default I think, as that is a pretty natural way to set it.

Most Liked

rgraff

rgraff OP

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? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews