zio icon indicating copy to clipboard operation
zio copied to clipboard

Issue with maps in config

Open wi101 opened this issue 1 year ago • 1 comments

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)

wi101 avatar Feb 05 '24 10:02 wi101

Thanks for reporting! Will take a look.

adamgfraser avatar Feb 05 '24 23:02 adamgfraser

/bounty $50

@wi101 Thanks for reporting!

jdegoes avatar Mar 07 '24 17:03 jdegoes

~~💎 $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 bountyShare on socials~~

Attempt Started (GMT+0) Solution
🔴 @Dev-abhishekkhaiwale Mar 9, 2024, 9:32:07 PM WIP
🟢 @wi101 #8714

algora-pbc[bot] avatar Mar 07 '24 17:03 algora-pbc[bot]

@Dev-abhishekkhaiwale: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] avatar Mar 16 '24 21:03 algora-pbc[bot]

The bounty is up for grabs! Everyone is welcome to /attempt #8661 🙌

algora-pbc[bot] avatar Mar 23 '24 21:03 algora-pbc[bot]

💡 @wi101 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar Apr 11 '24 07:04 algora-pbc[bot]

🎉🎈 @wi101 has been awarded $50! 🎈🎊

algora-pbc[bot] avatar Apr 11 '24 19:04 algora-pbc[bot]

resolved. #8714

wi101 avatar Apr 18 '24 09:04 wi101