Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter mapping and cascading do not work together sometimes #395

Open
ill-eye opened this issue Oct 26, 2023 · 0 comments
Open

Parameter mapping and cascading do not work together sometimes #395

ill-eye opened this issue Oct 26, 2023 · 0 comments

Comments

@ill-eye
Copy link

ill-eye commented Oct 26, 2023

When one datasource has a value defined in one style of parameter names and another in another it leads to values being "erased" from the final config.

E.g.

data class Config(
    val mySection: MySection
) {

    data class MySection(val test: Int, val subSection: SubSection) {
        data class SubSection(val someValue: Int)
    }

With a file config like this

my-section {
   test = 1
   sub-section { 
      some-value = 2
   }
}

And an environment variable like this

mySection.subSection.someValue = 3

Will result in mySection.test not being set.

I looked in the debugger and it seems that "mySection" and "my-section" are different paths when resolving config at the cascading stage, so "mySection.test" is undefined and that value overrides "my-section.test" that is set.

I don't know if it makes sense but if parameter mapping was applied already when preprocessing the configs so that the map has normalized names, and not at the point of reading from the map, it would prevent this kind of issue.
At least it might be worth noting in the docs that this is not allowed, because it's very hard to debug when it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant