Closed josevalim closed 6 years ago
Where do I configure this? I added to the Repo config and I'm still not seeing the exception.
bump
Which version are you using? How are you configuring it?
My problem is I don't know where to pass the show_sensitive_data_on_connection_error
option.
I tried it in the config.exs
as well as in the init callback of an ecto repo.
@narrowtux sorry but you still have answered the questions above. :) Which version are you using? How are you configuring it? Can you please provide code snippets? Thanks!
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
"ecto": {:hex, :ecto, "2.2.10", "e7366dc82f48f8dd78fcbf3ab50985ceeb11cb3dc93435147c6e13f2cda0992e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
defmodule MyApp.Repo do
use Ecto.Repo, otp_app: :my_app
require Logger
@doc """
Dynamically loads the repository url from the
DATABASE_URL environment variable.
"""
def init(_, opts) do
app_config = Application.get_env(:my_app, MyApp.Repo)
pool_size = case {System.get_env("EXPORTER_DATABASE_POOLSIZE"), Keyword.get(app_config, :pool_size, 10)} do
{nil, val} -> val
{val, _} -> val |> String.to_integer()
end
port = case {System.get_env("EXPORTER_DATABASE_PORT"), Keyword.get(app_config, :port, 5432)} do
{nil, val} -> val
{val, _} -> val |> String.to_integer()
end
opts = opts
|> Keyword.put(:database, System.get_env("EXPORTER_DATABASE_NAME") || Keyword.get(app_config, :database))
|> Keyword.put(:username, System.get_env("EXPORTER_DATABASE_USER") || Keyword.get(app_config, :username))
|> Keyword.put(:password, System.get_env("EXPORTER_DATABASE_PASSWORD") || Keyword.get(app_config, :password))
|> Keyword.put(:hostname, System.get_env("EXPORTER_DATABASE_HOST") || Keyword.get(app_config, :hostname))
|> Keyword.put(:port, port)
|> Keyword.put(:pool_size, pool_size)
|> Keyword.put(:show_sensitive_data_on_connection_error, true)
{:ok, opts}
end
end
This feature is only available on DBConnection 2.0, which is used by Ecto 3.0. You need to update Ecto.
Please also include your db_connection version.
I think setting show_sensitive_data_on_connection_error
to true
in the init is the correct way, we only had a problem with our release process which deployed a stale image which meant that I didn't see changes in the way the error was reported.
Note that I wasn't looking for a solution for the actual problem, just for how to set this option so I can see the problem and fix it myself.
Thank you for the quick responses.
:heart: :green_heart: :blue_heart: :yellow_heart: :purple_heart: