sksamuel / hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes
Apache License 2.0
924 stars 74 forks source link

Denormalization of map keys does not work correctly when loading from ENV with underscores #454

Open schmist opened 1 month ago

schmist commented 1 month ago

Loading a map key value pair (map__foo=bar) from ENV leads to a map key map__foo instead of foo. This used to work correctly for 2.7.x and is probably broken since 2.8.x.

The problem seems to be in the node denormalization method: (v.sourceKey ?: k).removePrefix("$sourceKey."). Either v.sourceKey needs to be transformed to map.foo before (when constructing the node) or the $sourceKey. prefix has to be adapted for source keys with underscores.

rocketraman commented 4 weeks ago

@schmist Can you verify the linked PR solves the issue for you?

schmist commented 4 weeks ago

@rocketraman Yep, I guess this will work. Thanks.