Search code examples
ktortypesafe-confighocon

Ktor parsing of arrays with nested objects config


I am trying to use the following configuration in Ktor:

source {
  quotes {
    inputTopicBaseName = "quotes"
    providers = [
      {
        provider = "BHS"
        windows = [
          {
            grace = "PT1M"
            size = "PT1M"
          }
        ]
      },
      {
        provider = "LSX"
        windows = [
          {
            grace = "PT1M"
            size = "PT1M"
          }
        ]
      }
    ]
  }
  type = QUOTES
}

When I invoke environment.config.config("source.quotes").configList("providers"), it fails with the following exception

Exception in thread "main" io.ktor.server.config.ApplicationConfigurationException: Property source.quotes.providers.size not found.
    at io.ktor.server.config.MapApplicationConfig.configList(MapApplicationConfig.kt:57)
    at io.ktor.server.config.MergedApplicationConfig.configList(MergedApplicationConfig.kt:37)

Why is this not working?


Solution

  • This is a bug that will be fixed in Ktor 2.2.0.