UPDATE3: (3 days latter) I found the root cause of failure in my case. My PHX_URL domain doesn’t match with email service provider that cause error in :create handler for user creation endpoint that was generated with mix phx.auth
and hasn’t been modified. Specifically I the error happening in Accounts.deliver_user_confirmation_instructions
which not able to deliver email dues to domain not being verified.
I was able to log the error by modifying ErrorView
as was suggested to me by @andrewf
What is interesting that the stack trace that I was able to get doesn’t actually provide any useful information about the failure.
15:04:26.993 request_id=FwVpWIEspi5kNgQAAAFR [error] 500 error:
%UndefinedFunctionError{arity: 4, function: :post, message: nil, module: false, reason: nil},
stack: [{false, :post, [["https://api.mailjet.com/v3.1", "/", "send"], [{"User-Agent", "swoosh/1.7.1"}, {"Authorization", "Basic MjFmNWEyOTE2MjJkZjViOGQ4NDZlYjE5YWMwNGQ4ZDk6Y2QwNDFiOGM5MWU3MzAzNWNhZmIzMDkxYjgzYjc3YmQ="}, {"Content-Type", "application/json"}], "{\"Messages\":[{\"From\":{\"Email\":\"robot@codercat.tk\",\"Name\":\"Draw All The Things!\"},\"Headers\":{},\"Subject\":\"Confirmation instructions\",\"TextPart\":\"\\n==============================\\n\\nHi example@gmail.com,\\n\\nYou can confirm your account by visiting the URL below:\\n\\nhttps://drawallthethings.com/users/confirm/xozIJSnFdNv4hMEnDKMFlR8rMIr5S7x2TT49fTBdkyQ\\n\\nIf you didn't create an account with us, please ignore this.\\n\\n==============================\\n\",\"To\":[{\"Email\":\"example@gmail.com\",\"Name\":\"\"}]}]}",
%Swoosh.Email{assigns: %{}, attachments: [], bcc: [], cc: [], from: {"Draw All The Things!", "robot@codercat.tk"}, headers: %{}, html_body: nil, private: %{}, provider_options: %{}, reply_to: nil, subject: "Confirmation instructions", text_body: "\n==============================\n\nHi example@gmail.com,\n\nYou can confirm your account by visiting the URL below:\n\nhttps://drawallthethings.com/users/confirm/xozIJSnFdNv4hMEnDKMFlR8rMIr5S7x2TT49fTBdkyQ\n\nIf you didn't create an account with us, please ignore this.\n\n==============================\n", to: [{"", "example@gmail.com"}]}], []},
{Swoosh.Adapters.Mailjet, :send_request, 3, [file: 'lib/swoosh/adapters/mailjet.ex', line: 92]},
{Codercat.Mailer, :"-instrument/3-fun-0-", 2, [file: 'lib/codercat/mailer.ex', line: 2]},
{:telemetry, :span, 3, [file: '/home/kiko/phx-codercat-dev/deps/telemetry/src/telemetry.erl', line: 320]}, {Codercat.Accounts.UserNotifier, :deliver, 3, [file: 'lib/codercat/accounts/user_notifier.ex', line: 15]},
{CodercatWeb.UserRegistrationController, :create, 2, [file: 'lib/codercat_web/controllers/user_registration_controller.ex', line: 17]},
{CodercatWeb.UserRegistrationController, :action, 2, [file: 'lib/codercat_web/controllers/user_registration_controller.ex', line: 1]},
{CodercatWeb.UserRegistrationController, :phoenix_controller_pipeline, 2, [file: 'lib/codercat_web/controllers/user_registration_controller.ex', line: 1]}]
What I really don’t understand is how come Phoenix framework doesn’t log this error by default. It is not even my custom weird code but rather code generated by Phoenix itself.