Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when code interface refers to invalid create action #1729

Open
RoyalIcing opened this issue Jan 23, 2025 · 1 comment
Open

KeyError when code interface refers to invalid create action #1729

RoyalIcing opened this issue Jan 23, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@RoyalIcing
Copy link
Contributor

Describe the bug
This exception is raised (KeyError) key :arguments not found in: nil

To Reproduce
Define an embedded resource like so:

defmodule Foo do
  use Ash.Resource, data_layer: :embedded

  actions do
    defaults [:read, :destroy]
  end

  attributes do
    uuid_primary_key :id
  end

  code_interface do
    define :create
  end
end

Expected behavior
I would expect a more helpful error telling me my code interface definition is incorrect.

Runtime

  • Elixir version 1.17.3
  • Erlang version 27
  • OS macOS 15.2
  • Ash version 3.4.47
@ken-kost
Copy link
Contributor

When you add a domain: use Ash.Resource, domain: Domain, data_layer: :embedded you get a more sensible error:

** (Spark.Error.DslError) [Foo]
interfaces -> interface -> create:
  The interface of Foo refers to a non-existent action create
    (ash 3.4.55) lib/ash/code_interface.ex:11: Ash.CodeInterface.require_action/2
    (stdlib 6.2) erl_eval.erl:919: :erl_eval.do_apply/7
    (stdlib 6.2) erl_eval.erl:663: :erl_eval.expr/6
    (stdlib 6.2) erl_eval.erl:271: :erl_eval.exprs/6
    (elixir 1.18.1) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
    (spark 2.2.36) /home/ken/nutrea/lib/nutrea/foo.ex:1: Spark.Dsl.__before_compile__/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Up Next
Development

No branches or pull requests

3 participants