(Protocol.UndefinedError) protocol Phoenix.HTML.Safe not implemented for %{errors: %{detail: "Internal Server Error"}}

I think what is happening is that the the user you’re trying to update is failing and your fallback controller aren’t transforming the error map into a string (That particular error is very common if when there is a data structure that cannot be directly transformed to a safe string).

If you try to add an else to the with clause in update/2 like this:/

with {:ok, user} <- Accounts.update_user(user, user_params) do

else
  {:error, _changeset} -> conn |> put_status(:unprocessable_entity) |> json(%{error: "Invalid params"})
end

You would at least see if that was the case. You could look into a fallback action (or a fallback controller) Phoenix.Controller — Phoenix v1.6.15