Ash Framework book - code interface search_artists error

I defined the code interface for the search action as search_artists.
define :search_artists, action: :search, args: [:query]

  1. When calling this i get the error the function is not defined, but i can call it as search_artist, without the “s”.
    Tunez.Music.search_artists(“fur”)
    **** (UndefinedFunctionError) function Tunez.Music.search_artists/1 is undefined or private. Did you mean:**

** * search_artist/0**
** * search_artist/1**
** * search_artist/2**
** * search_artist!/0**
** * search_artist!/1**

** (tunez 0.1.0) Tunez.Music.search_artists(“fur”)**
** iex:23: (file)**

  1. When calling Tunez.Music.search_artist without an arg, the artists are listed, but when i pass in the query arg “fur” i get enumerable error:
    Tunez.Music.search_artist(“fur”)

** (Protocol.UndefinedError) protocol Enumerable not implemented for type BitString

Got value:

"fur"

(elixir 1.18.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.18.2) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.18.2) lib/enum.ex:4511: Enum.reduce/3
(ash 3.4.71) lib/ash/resource/interface.ex:133: Ash.Resource.Interface.ReadOpts.validate!/1
(tunez 0.1.0) deps/ash/lib/ash/code_interface.ex:592: anonymous fn/1 in Tunez.Music.search_artist/2
(ash 3.4.71) lib/ash/code_interface.ex:277: anonymous fn/2 in Ash.CodeInterface.params_and_opts/3
(tunez 0.1.0) deps/ash/lib/ash/code_interface.ex:584: Tunez.Music.search_artist/2
iex:23: (file)

It really sounds like you made a typo with your code interface and wrote search_artist instead of search_artists. I’d double check your code interface.

If the problem persists, please push your code to GitHub and I’ll take a look :slight_smile:

1 Like

Hi Rebecca, Here is the repo. GitHub - Raathmd/tunez

Enjoying the book. thanks

I’m not seeing search_artist (without an s) anywhere in your code. Did you restart your 'iex`, or recompile, after adding the code interface?

Sorry, i thought i had restarted the IEX session. The search_artists(1) function is now valid. New at elixir mistake.

1 Like

All good, it happens! Glad it’s sorted now :slight_smile: