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

UndefinedFunctionError when destroying a resource via ash_admin #46

Closed
sevenseacat opened this issue May 23, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@sevenseacat
Copy link
Contributor

Describe the bug
I noticed it while testing stuff in ash_admin but I believe the root cause is here.

When destroying a record via ash_admin, the following error is raised:

** (UndefinedFunctionError) function :ok.resource/0 is undefined (module :ok is not available)
    :ok.resource()
    (ash 1.52.0-rc.8) lib/ash/api/api.ex:987: Ash.Api.update/3
    (my_app 0.1.0) lib/my_app/ash/api.ex:1: MyApp.Api.update/2
    (ash_phoenix 0.7.2-rc.0) lib/ash_phoenix/form/form.ex:1160: AshPhoenix.Form.with_changeset/2
    (ash_phoenix 0.7.2-rc.0) lib/ash_phoenix/form/form.ex:1076: AshPhoenix.Form.submit/2
    (ash_admin 0.4.4) lib/ash_admin/components/resource/form.ex:1083: AshAdmin.Components.Resource.Form.handle_event/3

Looking at that line of ash_phoenix, it looks like it's trying to call an update function after a destroy? Which was introduced as part of this commit:

50f6a10#diff-9cf68247dcbdd870091032f2ed3c7f1ac6ee87d1dfb2051658c4e61cab2fe3efR1074

Should this line have been added?

To Reproduce

I'm not sure how to trigger it outside ash_admin. But within ash_admin, triggering a Destroy action will cause it.

Expected behavior

The action does actually delete the record, but the LV crashes and so the app is left on a white screen - this shouldn't happen, it should go back to the default read action or schema or something with a flash message. Whatever it did before the bug was introduced!

** Runtime

  • Elixir version - 1.13.3
  • Erlang version - 24.3
  • OS - macOS Monterey
  • Ash/AshPhoenix/AshAdmin version - current main
@sevenseacat sevenseacat added the bug Something isn't working label May 23, 2022
@zachdaniel
Copy link
Contributor

Ah, great catch! The call to destroy before the with_changeset should have been removed. Will push a fix shortly.

@sevenseacat
Copy link
Contributor Author

Fixed by 6f48087

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
None yet
Development

No branches or pull requests

2 participants