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

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
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

We're in Beta

About us Mission Statement