zio
zio copied to clipboard
Issue with maps in config
Hello,
There is a failure while parsing the configuration. Specifically while reading a map using table
(defined in zio)
This is an example using the zio version: 2.0.21 and the zio-config: 4.0.1
The application.conf
:
example {
settings {
key1: "value1"
key2: "value2"
key3: "value3"
}
}
And this is the zio code:
import zio.Console.printLine
import zio._
import zio.config.magnolia.deriveConfig
import zio.config.typesafe.TypesafeConfigProvider
object Main extends ZIOAppDefault {
final case class ExampleConf(settings: Map[String, String])
override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
Runtime.setConfigProvider(
TypesafeConfigProvider
.fromResourcePath()
.kebabCase)
def layer =
ZLayer(ZIO.configProviderWith(_.nested("example").load(deriveConfig[ExampleConf])))
.tap(c =>printLine(s"the configuration is: $c"))
.tapError(e => printLine(s"parse config failed with: $e"))
override def run = {
ZLayer.make[ExampleConf](layer)
.launch
.exitCode
}
}
The output:
[info] parse config failed with: (Missing data at example.example.settings.key1: Expected example?example?settings?key1 to be set in properties)
Thanks for reporting! Will take a look.
/bounty $50
@wi101 Thanks for reporting!
~~💎 $50 bounty created by ZIO~~
~~🙋 If you start working on this, comment /attempt #8661
along with your implementation plan~~
~~👉 To claim this bounty, submit a pull request that includes the text /claim #8661
somewhere in its body~~
~~📝 Before proceeding, please make sure you can receive payouts in your country~~
~~💵 Payment arrives in your account 2-5 days after the bounty is rewarded~~
~~💯 You keep 100% of the bounty award~~
~~🙏 Thank you for contributing to zio/zio!~~
~~👉 Add a bounty • Share on socials~~
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @Dev-abhishekkhaiwale | Mar 9, 2024, 9:32:07 PM | WIP |
🟢 @wi101 | #8714 |
@Dev-abhishekkhaiwale: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
The bounty is up for grabs! Everyone is welcome to /attempt #8661
🙌
💡 @wi101 submitted a pull request that claims the bounty. You can visit your bounty board to reward.
resolved. #8714