carlgleisner

carlgleisner

Expected action of type :update, but :destroy is of type :destroy

Dear community,

I’ve set up AshAdmin and upon applying the delete action on my resource I get the following error:

** (ArgumentError) Expected action of type :update, but :destroy is of type :destroy

I’ve done a thorough search of the forum and elsewhere (not Discord though). Look, I’m sure I’m “holding it wrong” but I really haven’t been able to find this issue documented, let alone any solution to it.

Does this make sense to anyone?

Any help would truly be appreciated.

Output

[debug] QUERY OK source="my_resource" db=0.2ms idle=1419.1ms
SELECT a0."id", a0."resource_type", a0."status" FROM "my_resource" AS a0 WHERE (a0."id"::uuid = $1::uuid) ["d6d0580a-07d0-428b-a881-e5979bf80ee4"]
↳ anonymous fn/3 in AshPostgres.DataLayer.run_query/2, at: lib/data_layer.ex:684
[info] Sent 500 in 77ms
[error] GenServer #PID<0.1135.0> terminating
** (ArgumentError) Expected action of type :update, but :destroy is of type :destroy
    (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:855: AshPhoenix.Form.require_action!/3
    (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:650: AshPhoenix.Form.for_destroy/3
    (ash_admin 0.10.2) lib/ash_admin/components/resource/form.ex:1627: AshAdmin.Components.Resource.Form.assign_form/1
    (ash_admin 0.10.2) lib/ash_admin/components/resource/form.ex:37: AshAdmin.Components.Resource.Form.update/2
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/utils.ex:498: Phoenix.LiveView.Utils.maybe_call_update!/3
    (elixir 1.16.0) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/diff.ex:681: anonymous fn/4 in Phoenix.LiveView.Diff.render_pending_components/6
    (telemetry 1.2.1) /Users/myusername/Developer/my_app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/diff.ex:676: anonymous fn/4 in Phoenix.LiveView.Diff.render_pending_components/6
    (stdlib 5.1.1) maps.erl:416: :maps.fold_1/4
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/diff.ex:635: Phoenix.LiveView.Diff.render_pending_components/6
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/diff.ex:143: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/static.ex:249: Phoenix.LiveView.Static.to_rendered_content_tag/4
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/static.ex:132: Phoenix.LiveView.Static.render/3
    (phoenix_live_view 0.20.4) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
    (phoenix 1.7.11) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
    (my_app 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2
    (my_app 0.1.0) deps/plug/lib/plug/debugger.ex:136: MyAppWeb.Endpoint."call (overridable 3)"/2
    (my_app 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2
    (phoenix 1.7.11) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
Last message: {:continue, :handle_connection}
State: {%ThousandIsland.Socket{socket: #Port<0.65>, transport_module: ThousandIsland.Transports.TCP, read_timeout: 60000, silent_terminate_on_error: false, span: %ThousandIsland.Telemetry{span_name: :connection, telemetry_span_context: #Reference<0.56314858.2486435844.140628>, start_time: -576460524402657788, start_metadata: %{remote_port: 50519, remote_address: {127, 0, 0, 1}, telemetry_span_context: #Reference<0.56314858.2486435844.140628>, parent_telemetry_span_context: #Reference<0.56314858.2486435844.139854>}}}, %{opts: %{websocket: [], http_1: [], http_2: []}, plug: {Phoenix.Endpoint.SyncCodeReloadPlug, {MyAppWeb.Endpoint, []}}, handler_module: Bandit.InitialHandler, http_1_enabled: true, http_2_enabled: true, websocket_enabled: true}}

Dependencies

  ash 2.18.2
  ash_admin 0.10.2
  ash_authentication 3.12.2
  ash_authentication_phoenix 1.9.0
  ash_phoenix 1.2.26
  ash_postgres 1.4.0
  assent 0.2.9
  bandit 1.2.0
  bcrypt_elixir 3.1.0
  castore 1.0.5
  comeonin 5.4.0
  comparable 1.0.0
  db_connection 2.6.0
  decimal 2.1.1
  dns_cluster 0.1.3
  earmark 1.4.46
  ecto 3.11.1
  ecto_sql 3.11.1
  elixir_make 0.7.8
  esbuild 0.8.1
  ets 0.9.0
  expo 0.5.1
  file_system 0.2.10
  finch 0.17.0
  floki 0.35.3
  gettext 0.24.0
  hpax 0.1.2
  jason 1.4.1
  joken 2.6.0
  jose 1.11.6
  mime 2.0.5
  mint 1.5.2
  nimble_options 1.1.0
  nimble_pool 1.0.0
  phoenix 1.7.11
  phoenix_ecto 4.4.3
  phoenix_html 3.3.3
  phoenix_live_dashboard 0.8.3
  phoenix_live_reload 1.4.1
  phoenix_live_view 0.20.4
  phoenix_pubsub 2.1.3
  phoenix_template 1.0.4
  phoenix_view 2.0.3
  picosat_elixir 0.2.3
  plug 1.15.3
  plug_crypto 2.0.0
  postgrex 0.17.4
  slugify 1.3.1
  sourceror 0.14.1
  spark 1.1.54
  stream_data 0.6.0
  swoosh 1.15.1
  tails 0.1.8
  tailwind 0.2.2
  telemetry 1.2.1
  telemetry_metrics 0.6.2
  telemetry_poller 1.0.0
  thousand_island 1.3.2
  typable 0.3.0
  websock 0.5.3
  websock_adapter 0.5.5

Resource

defmodule MyApp.MyApi.MyResource do
  use Ash.Resource,
    data_layer: AshPostgres.DataLayer,
    extensions: [AshAdmin.Resource]

  attributes do
    uuid_primary_key :id

    attribute :resource_type, :atom do
      constraints one_of: [:a, :b, :c]
    end

    attribute :status, :atom do
      constraints one_of: [:created, :processing, :succeeded, :failed]

      default :created
    end
  end

  actions do
    defaults [:create, :read, :update, :destroy]
  end

  postgres do
    table "my_resource"
    repo MyApp.Repo
  end
end

Ash API

defmodule MyApp.MyApi do
  use Ash.Api,
    extensions: [AshAdmin.Api]

  admin do
    show? true
  end

  resources do
    resource MyApp.MyApi.MyResource
  end
end

Config

# Ash Framework
config :my_app,
  ash_apis: [MyApp.MyOtherApi, MyApp.MyApi]

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Thank you for the reproduction :slight_smile: I’ve pushed a fix up, and published new versions of ash_admin and ash_phoenix. You’ll also need to update phoenix_html to ~> 4.0 to use the latest versions of those packages.

Also Liked

zachdaniel

zachdaniel

Creator of Ash

This looks like a bug in ash admin internals actually :sob: don’t think you’re doing anything wrong at all. I’ll take a look later today.

carlgleisner

carlgleisner

Phew, then it’s not just me (perhaps) :face_exhaling:

Thanks for taking the time to comment. I’ll send you an invite as a collaborator on a repo that reproduces the issue.

Thanks for an amazing job on Ash!

carlgleisner

carlgleisner

Wow – thank you Zach!

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New

We're in Beta

About us Mission Statement