Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested data structs are not resolved as expected #55

Open
paveltyk opened this issue Feb 6, 2024 · 0 comments
Open

Nested data structs are not resolved as expected #55

paveltyk opened this issue Feb 6, 2024 · 0 comments

Comments

@paveltyk
Copy link

paveltyk commented Feb 6, 2024

An OTP app config with nested data structs evaluates to nil if at least one entry specifies system env var that is not set.

Example:

config :my_app,
  var: [
    foo: {:system, :string, "FOO"},
    bar: "bar-value"
  ]

Expected:

iex> Confex.get_env(:my_app, :var)

[
  foo: nil,
  bar: "bar-value"
]

Less expected, but still meaningful:

iex> Confex.get_env(:my_app, :var)

[
  bar: "bar-value"
]

Actual:

iex> Confex.get_env(:my_app, :var)

nil

Workaround:

Use 4 element tuple with a default value of nil

config :my_app,
  var: [
    foo: {:system, :string, "FOO", nil},
    bar: "bar-value"
  ]

####

iex> Confex.get_env(:my_app, :var)

[
  foo: nil,
  bar: "bar-value"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant