Skip to content

Nested data structs are not resolved as expected #55

Description

@paveltyk

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"
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions