Chrichton

Chrichton

I am creating an admin app with data similar to the Tunez app from the Ash book from PragPro.
I want to query the artists by name sorted by name.

Using the tunez code, I am able to query via:

 Tunez.Music.search_artists!("a", query: [sort_input: "name"])

When querying with my app via:

Tuneshg.Music.search_artists!("a", query: [sort_input: "name"])

I get:

** (Ash.Error.Invalid) 
Invalid Error

* No such field name for resource Tuneshg.Music.Artist
    at sort
  (ash 3.4.55) lib/ash/error/query/no_such_field.ex:5: Ash.Error.Query.NoSuchField.exception/1
  (ash 3.4.55) lib/ash/sort/sort.ex:210: Ash.Sort.parse_sort/3
  (ash 3.4.55) lib/ash/sort/sort.ex:131: anonymous fn/4 in Ash.Sort.parse_input/3
  (elixir 1.18.1) lib/enum.ex:4964: Enumerable.List.reduce/3
  (elixir 1.18.1) lib/enum.ex:2600: Enum.reduce_while/3
  (ash 3.4.55) lib/ash/sort/sort.ex:130: Ash.Sort.parse_input/3
  (ash 3.4.55) lib/ash/query/query.ex:323: Ash.Query.sort_input/3
  (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
  (tuneshg 0.1.0) deps/ash/lib/ash/code_interface.ex:676: Tuneshg.Music.search_artists!/3
  (elixir 1.18.1) src/elixir.erl:386: :elixir.eval_external_handler/3
  (stdlib 6.2) erl_eval.erl:919: :erl_eval.do_apply/7
  (elixir 1.18.1) src/elixir.erl:364: :elixir.eval_forms/4
  (elixir 1.18.1) lib/module/parallel_checker.ex:120: Module.ParallelChecker.verify/1
  (iex 1.18.1) lib/iex/evaluator.ex:336: IEx.Evaluator.eval_and_inspect/3
  (iex 1.18.1) lib/iex/evaluator.ex:310: IEx.Evaluator.eval_and_inspect_parsed/3
  (iex 1.18.1) lib/iex/evaluator.ex:299: IEx.Evaluator.parse_eval_inspect/4
  (iex 1.18.1) lib/iex/evaluator.ex:189: IEx.Evaluator.loop/1
  (iex 1.18.1) lib/iex/evaluator.ex:34: IEx.Evaluator.init/5
  (stdlib 6.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
    (ash 3.4.55) lib/ash/error/invalid.ex:3: Ash.Error.Invalid.exception/1
    (ash 3.4.55) /Volumes/Quizzlab/Projects/tuneshg/deps/splode/lib/splode.ex:264: Ash.Error.to_class/2
    (ash 3.4.55) lib/ash/error/error.ex:108: Ash.Error.to_error_class/2
    (ash 3.4.55) lib/ash/actions/read/read.ex:29: Ash.Actions.Read.run/3
    (ash 3.4.55) lib/ash.ex:2008: Ash.read/2
    (ash 3.4.55) lib/ash.ex:1966: Ash.read!/2
    iex:4: (file)

The artist search action, and attributes are the same
The album define :search_artists are the same.

What could be the reason for the Ash.Error?
How can I evaluate what field is missing?

Thanks for your reply, Heiko

Showing Posts 1 to 2

sevenseacat

sevenseacat

Author of Ash Framework

The name attribute needs to be marked as public? true :slight_smile:

As sort_input is intended for use with untrusted input, such as from a query string, you need to explicitly allow each field that you allow to be sorted on, by making them public.

Chrichton

Chrichton OP

Oh my.

Thank you again Rebecca.
Again you are right :sweat_smile:

And you are faster than lightning!

It works and now my admin tool for Artists and Albums is complete.

I promise not to ask anything today :innocent:

Have a nice Saturday.

Best wishes from Heiko

— All posts loaded —

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
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
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
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
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

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
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews