Skip to content

Inheritance breaks configuration file overlays #812

@danielyli

Description

@danielyli

Typesafe config version: 1.4.3

Summary

When a configuration object uses inheritance, non-optional environment variables are searched for before further file overlays are applied, which breaks file overlays.

Reproduction Steps

Create the following two configuration files:

File: src/main/resources/application.conf

base = {}
child = ${base} {
  foo = ${FOOBAR}
}

File: src/test/resources/application.conf

child.foo = "test-foo"

When attempting to run sbt test, the following error will appear:

Caused by: sbt.ForkMain$ForkError: com.typesafe.config.ConfigException$UnresolvedSubstitution:
application.conf @ file:/[...]/target/scala-2.13/classes/application.conf: 248: Could not resolve
substitution to a value: ${FOOBAR}

In contrast, if we change src/main/resources/application.conf to be the following, the error does not appear and child.foo is correctly set to test-foo:

child = {
  foo = ${FOOBAR}
}

Expected Behavior

The configuration value for child.foo should be test-foo for both cases.

Actual Behavior

Inheritance breaks the first case.

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