Skip to content

config() returns nil when resolving configuration fails #45

@indrekj

Description

@indrekj

The comment https://github.com/Nebo15/confex/blob/master/lib/confex.ex#L314 says that ArgumentError is raised when configuration cannot be resolved. This however is not true.

Here you can see the configuration:

iex(1)> {:ok, c} = Application.fetch_env(:transporter, Transporter.ProxyRequests.Process)
{:ok,
 [
   bypass: %{
     ~r/\/\/client-logger\..*/ => %{
       host: {:system, "CLIENT_LOGGER_SERVICE_HOST"},
       port: 80,
       scheme: "http"
     }
   }
 ]}

CLIENT_LOGGER_SERVICE_HOST env var is not actually set.

If I use use Confex, otp_app: :transporter macro, then Transporter.ProxyRequests.Process.config() returns just nil.

I think this is because Confex is using get_env https://github.com/Nebo15/confex/blob/master/lib/confex.ex#L319 which defaults to nil on error.

Feel free to close this ticket if this behavior is expected. It caused us a small incident because one of the env vars was missing and it didn't fail fast.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions