albin
Transaction rollback with no errors when adding ash_events to `User` resource created by `AshAuthentication` installer
On a fresh project with ash_authentication installed, an insert into the user table triggers a rollback. However, it works fine for other simple resources.
[info] GET /register
[debug] Processing with AshAuthentication.Phoenix.SignInLive.register/2
Parameters: %{}
Pipelines: [:browser]
[info] Sent 200 in 3ms
[info] CONNECTED TO Phoenix.LiveView.Socket in 13µs
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Parameters: %{"_csrf_token" => "WQAnQHAKB3MZCgFGClQUGxkoFCQoK38L-qh2AgKDObo2MeZOoxywNRGA", "_live_referer" => "undefined", "_mount_attempts" => "0", "_mounts" => "0", "_track_static" => %{"0" => "http://localhost:4000/assets/app.css", "1" => "http://localhost:4000/assets/app.js"}, "vsn" => "2.0.0"}
[debug] MOUNT AshAuthentication.Phoenix.SignInLive
Parameters: %{}
Session: %{"_csrf_token" => "tqOr1mL7VhntG1NTvPmSfy8J", "auth_routes_prefix" => "/auth", "context" => nil, "gettext_fn" => nil, "otp_app" => nil, "overrides" => [AshEventsTestWeb.AuthOverrides, AshAuthentication.Phoenix.Overrides.Default], "path" => "/sign-in", "register_path" => "/register", "reset_path" => "/reset", "resources" => nil, "tenant" => nil}
[debug] Replied in 122µs
[debug] HANDLE PARAMS in AshAuthentication.Phoenix.SignInLive
Parameters: %{}
[debug] Replied in 11µs
[debug] HANDLE EVENT "change" in AshAuthentication.Phoenix.SignInLive
Component: AshAuthentication.Phoenix.Components.Password.RegisterForm
Parameters: %{"_csrf_token" => "JD57KkslfGQ1BDg7BHQ7GhMCOzxXGlEkPO4XzH0SclVOCEuNeRVo1cin", "_target" => ["user", "email"], "user" => %{"_unused_password" => "[FILTERED]", "_unused_password_confirmation" => "[FILTERED]", "email" => "haha@lol.", "password" => "[FILTERED]", "password_confirmation" => "[FILTERED]"}}
[debug] Replied in 1ms
[debug] HANDLE EVENT "change" in AshAuthentication.Phoenix.SignInLive
Component: AshAuthentication.Phoenix.Components.Password.RegisterForm
Parameters: %{"_csrf_token" => "JD57KkslfGQ1BDg7BHQ7GhMCOzxXGlEkPO4XzH0SclVOCEuNeRVo1cin", "_target" => ["user", "email"], "user" => %{"_unused_password" => "[FILTERED]", "_unused_password_confirmation" => "[FILTERED]", "email" => "haha@lol.com", "password" => "[FILTERED]", "password_confirmation" => "[FILTERED]"}}
[debug] Replied in 1ms
[debug] HANDLE EVENT "change" in AshAuthentication.Phoenix.SignInLive
Component: AshAuthentication.Phoenix.Components.Password.RegisterForm
Parameters: %{"_csrf_token" => "JD57KkslfGQ1BDg7BHQ7GhMCOzxXGlEkPO4XzH0SclVOCEuNeRVo1cin", "_target" => ["user", "password"], "user" => %{"_unused_password_confirmation" => "[FILTERED]", "email" => "haha@lol.com", "password" => "[FILTERED]", "password_confirmation" => "[FILTERED]"}}
[debug] Replied in 1ms
[debug] HANDLE EVENT "change" in AshAuthentication.Phoenix.SignInLive
Component: AshAuthentication.Phoenix.Components.Password.RegisterForm
Parameters: %{"_csrf_token" => "JD57KkslfGQ1BDg7BHQ7GhMCOzxXGlEkPO4XzH0SclVOCEuNeRVo1cin", "_target" => ["user", "password_confirmation"], "user" => %{"email" => "haha@lol.com", "password" => "[FILTERED]", "password_confirmation" => "[FILTERED]"}}
[debug] Replied in 1ms
[debug] HANDLE EVENT "submit" in AshAuthentication.Phoenix.SignInLive
Component: AshAuthentication.Phoenix.Components.Password.RegisterForm
Parameters: %{"_csrf_token" => "JD57KkslfGQ1BDg7BHQ7GhMCOzxXGlEkPO4XzH0SclVOCEuNeRVo1cin", "user" => %{"email" => "haha@lol.com", "password" => "[FILTERED]", "password_confirmation" => "[FILTERED]"}}
[debug] QUERY OK db=0.6ms idle=1283.2ms
begin []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:3760
[debug] QUERY OK db=0.5ms
SELECT pg_advisory_xact_lock($1) [2147483647]
[debug] QUERY OK source="events" db=2.0ms
INSERT INTO "events" ("data","version","metadata","resource","action","action_type","occurred_at","record_id") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "user_id","record_id","occurred_at","system_actor","action_type","action","resource","metadata","version","data","id" [%{password: "asdfasdf", email: #Ash.CiString<"haha@lol.com">, password_confirmation: "asdfasdf"}, 1, %{}, AshEventsTest.Accounts.User, :register_with_password, :create, ~U[2025-05-24 16:13:04.472551Z], "f4e3ef2d-2f6d-48e5-ba52-7bc4a7c26017"]
↳ AshPostgres.DataLayer.bulk_create/3, at: lib/data_layer.ex:1979
[debug] QUERY OK db=0.5ms
rollback []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:3760
[debug] Replied in 15ms
To Reproduce
Here’s a minimal reproduction of the issue: GitHub - albinkc/ash_events_test · GitHub
Expected behavior
An Error stating the reason for the transaction rollback.
** Runtime
-
Erlang/OTP 27 [erts-15.2.7] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
-
Elixir 1.18.3 (compiled with Erlang/OTP 27)
-
MacOS 15.5
Additional context
FWIW, Tried on both PG 17 and 18
Most Liked
zachdaniel
Hmm…mayhaps another separate issue with ash_events somehow?
Can you put together a reproduction project and open and issue? Obviously ash_events wasn’t tested event sourcing on the user resource using AshAuthentication ![]()
zachdaniel
Yes, we could write a verifier that discovers that. Please open an issue (make sure the word “verifier” is mentioned, because if its not done in a verifier it will incur a compile time dependency).
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








