Skip to content

Regression in environment variable reading behavior #802

@ilinandrii

Description

@ilinandrii

Starting from 1.4.1 this code behaves differently then previously:

ConfigFactory.systemEnvironmentOverrides().withFallback(ConfigFactory.systemProperties)

Here's the simple test. Run this application with environment variable VARIABLE set to any String

import com.typesafe.config.ConfigFactory

//VARIABLE=test

object Test extends App {
  val env = ConfigFactory.systemEnvironmentOverrides().withFallback(ConfigFactory.systemProperties)
  println(env.getString("VARIABLE"))
}

implementation('com.typesafe:config:1.4.0')
Output:

> Task :Test.main()
test

implementation('com.typesafe:config:1.4.1')
Output

> Task :Test.main() FAILED
Exception in thread "main" com.typesafe.config.ConfigException$Missing: system properties: No configuration setting found for key 'VARIABLE'
	at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:157)
	at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:175)
	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:194)
	at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:251)
	at Test$.delayedEndpoint$Test$1(Test.scala:6)
	at Test$delayedInit$body.apply(Test.scala:3)
	at scala.Function0.apply$mcV$sp(Function0.scala:42)
	at scala.Function0.apply$mcV$sp$(Function0.scala:42)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1(App.scala:98)
	at scala.App.$anonfun$main$1$adapted(App.scala:98)
	at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:575)
	at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:573)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:933)
	at scala.App.main(App.scala:98)
	at scala.App.main$(App.scala:96)
	at Test$.main(Test.scala:3)
	at Test.main(Test.scala)

I've printed config as well and made a text search for VARIABLE and indeed no such variable there.

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