I’m trying to convert this to a simple url config but everything i’ve tried just isn’t working, I’ve tried just about every url config imaginable and none work.
** (RuntimeError) Connect raised a KeyError error.
Sure, this is the error I get when I try your url…
[error] GenServer #PID<0.320.0> terminating
** (RuntimeError) Connect raised a KeyError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.
(elixir) lib/keyword.ex:377: Keyword.fetch!/2
(postgrex) lib/postgrex/protocol.ex:98: Postgrex.Protocol.connect/1
(db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
Sad I had hoped you had for some reason a pre 2.0 ecto.
So the root cause is something else.
I took a look into the postgrex as well, and assuming you had 0.13.5, then the only thing that can raise on line 98 is Keyword.fetch!(opts, :database)
For me it looks as if database is extracted correctly from the URL when I look at the parse_url/1 from ecto. And for me it looks as if it is properly merged into the options for the adapter.
Yeah its really weird. I don’t understand whats going on, but for now only solution is to split the config back to how it was originally and avoid using a database url:
Yeah I am using 0.13.5… oh well, thanks for trying to help!
For anyone in the future with this problem, it was a problem in my Repo.init/2
It was overriding the :url variable with a system variable that was undefined.
Apparently if you use Ecto as a standalone it generates repo code that automatically overrides :url with a system variable making the :url setting useless unless the code is removed.
This was patched in phoenix where it checks if the system variable exists before overriding, but not in ecto…