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

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews