tfwright / live_admin

Low-config admin UI for Phoenix apps, built on LiveView
MIT License
251 stars 22 forks source link

Use of reserved `:socket` assign results in 500 on LiveView 0.18.17. #29

Closed jmillxyz closed 1 year ago

jmillxyz commented 1 year ago

Describe the bug Updating to LiveView 0.18.17 results in ** (ArgumentError) :socket is a reserved assign by LiveView and it cannot be set directly when visiting the LiveAdmin index page.

To Reproduce Upgrade to LiveView 0.18.17, and visit the LiveAdmin index page.

[info] Sent 500 in 162ms
[error] #PID<0.1201.0> running BeaconWeb.Endpoint (connection #PID<0.1083.0>, stream id 22) terminated
Server: localhost:4000 (http)
Request: GET /admin
** (exit) an exception was raised:
    ** (ArgumentError) :socket is a reserved assign by LiveView and it cannot be set directly
        (phoenix_live_view 0.18.17) lib/phoenix_component.ex:1258: Phoenix.Component.validate_assign_key!/1
        (phoenix_live_view 0.18.17) lib/phoenix_component.ex:1209: Phoenix.Component.assign/3
        (elixir 1.14.1) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
        (live_admin 0.7.2) lib/live_admin/router.ex:81: LiveAdmin.Router.on_mount/4
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/lifecycle.ex:149: anonymous fn/4 in Phoenix.LiveView.Lifecycle.mount/3
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/lifecycle.ex:215: Phoenix.LiveView.Lifecycle.reduce_socket/3
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/utils.ex:389: anonymous fn/6 in Phoenix.LiveView.Utils.maybe_call_live_view_mount!/5
        (telemetry 1.2.1) /Users/jmill/code/viabeacon/beacon/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/static.ex:278: Phoenix.LiveView.Static.call_mount_and_handle_params!/5
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/static.ex:119: Phoenix.LiveView.Static.render/3
        (phoenix_live_view 0.18.17) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
        (phoenix 1.6.16) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
        ...(application code omitted)

Environment:

tfwright commented 1 year ago

Hi, thanks for the report. I have reproduced this locally and will look into a fix. I'm guessing it's just a matter of avoiding a reserved term.

jmillxyz commented 1 year ago

Amazing, thank you!

tfwright commented 1 year ago

I think the changes in this branch should do it: https://github.com/tfwright/live_admin/tree/0.7.3

When you get a chance, try it out and let me know. If it resolves the issue I'll release an update.

jmillxyz commented 1 year ago

Yep, that resolves it for me! Thank you for the quick fix 🙂

tfwright commented 1 year ago

Resolved in 622723240975a6a0ec9d11b8dc2032f5009586bd