zac

zac

Ash / Phoenix deps update results in /sign-in error: Cannot set assign `current_members` before default `AshAuthentication.Phoenix.LiveSession.on_mount/4` has run

I just ran a relatively minor deps update on my Ash / Ash Auth / Phoenix project:

Upgraded:
  ash 3.5.32 => 3.5.36
  ash_authentication 4.9.8 => 4.9.9
  ash_authentication_phoenix 2.10.4 => 2.10.5
  ash_phoenix 2.3.11 => 2.3.14
  ash_postgres 2.6.13 => 2.6.16
  ash_sql 0.2.89 => 0.2.90
  bandit 1.7.0 => 1.8.0
  castore 1.0.14 => 1.0.15
  cc_precompiler 0.1.10 => 0.1.11
  fine 0.1.1 => 0.1.4
  igniter 0.6.25 => 0.6.28
  lazy_html 0.1.3 => 0.1.6
  phoenix 1.8.0-rc.4 => 1.8.0
  phoenix_live_view 1.1.0-rc.4 => 1.1.8
  postgrex 0.20.0 => 0.21.1 (minor)
  spark 2.2.67 => 2.2.68
  thousand_island 1.3.14 => 1.4.0

Probably the most notable was Phoenix Live View 1.1.0-rc4 → 1.1.8 (eek, not sure why that was stuck back there). Pretty minor Ash deps upgrade…

And now when I hit /sign-in (or, any other page that requires an authenticated user) I’m getting this:

[error] ** (RuntimeError) Cannot set assign `current_members` before default `AshAuthentication.Phoenix.LiveSession.on_mount/4` has run.
    (ash_authentication_phoenix 2.10.5) lib/ash_authentication_phoenix/live_session.ex:174: anonymous fn/5 in AshAuthentication.Phoenix.LiveSession.on_mount/4
    (elixir 1.18.4) lib/enum.ex:4515: anonymous fn/3 in Enum.reduce/3
    (elixir 1.18.4) lib/stream.ex:1761: anonymous fn/3 in Enumerable.Stream.reduce/3
    (elixir 1.18.4) lib/enum.ex:4968: Enumerable.List.reduce/3
    (elixir 1.18.4) lib/stream.ex:1773: Enumerable.Stream.do_each/4
    (elixir 1.18.4) lib/enum.ex:4515: Enum.reduce/3
    (ash_authentication_phoenix 2.10.5) lib/ash_authentication_phoenix/live_session.ex:170: AshAuthentication.Phoenix.LiveSession.on_mount/4
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/lifecycle.ex:158: anonymous fn/4 in Phoenix.LiveView.Lifecycle.mount/3
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/lifecycle.ex:237: Phoenix.LiveView.Lifecycle.reduce_socket/3
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/utils.ex:346: anonymous fn/6 in Phoenix.LiveView.Utils.maybe_call_live_view_mount!/5
    (telemetry 1.3.0) /Users/zac/Projects/BossLogic/waste_walk/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/static.ex:324: Phoenix.LiveView.Static.call_mount_and_handle_params!/5
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/static.ex:155: Phoenix.LiveView.Static.do_render/4
    (phoenix_live_view 1.1.8) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
    (phoenix 1.8.0) lib/phoenix/router.ex:416: Phoenix.Router.__call__/5
    (waste_walk 0.1.0) lib/waste_walk_web/endpoint.ex:1: WasteWalkWeb.Endpoint.plug_builder_call/2
    (waste_walk 0.1.0) deps/plug/lib/plug/debugger.ex:155: WasteWalkWeb.Endpoint."call (overridable 3)"/2
    (waste_walk 0.1.0) lib/waste_walk_web/endpoint.ex:1: WasteWalkWeb.Endpoint.call/2
    (phoenix 1.8.0) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
    (bandit 1.8.0) lib/bandit/pipeline.ex:131: Bandit.Pipeline.call_plug!/2

Which is kind of a black-box thing to break. Any ideas how I can diagnose and fix it?

I’m suspecting that perhaps my Ash Authentication original config is somehow out of date (maybe run a new igniter project, compare the results)… or… kinda at a loss.

//Edit

Well, generated a parallel project with latest libs. I don’t see any obvious differences between the new and the old, looked at all the config files, things like live_user_auth.ex etc., I don’t see any significant delta. Really weird.

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Why add the ash authentication extension to this resource?

Last Post!

zachdaniel

zachdaniel

Creator of Ash

It being on two resources is actually one of the first issues I asked about :joy:. The plug for setting the actor uses the “subject name” to assign to the socket or the conn, i.e “current_members”. It ensures that the assign is always present but nil if no token was given. We should provide a better error there naturally, but in this case the second pass failed thinking someone had touched its assign and was trying to warn you not to mess with it.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

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 54921 245
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement