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

Substitution can break overrides #256

Closed
JettJones opened this issue Mar 6, 2021 · 0 comments
Closed

Substitution can break overrides #256

JettJones opened this issue Mar 6, 2021 · 0 comments

Comments

@JettJones
Copy link
Contributor

I expect that overrides would replace the previous values when merging objects. In this example that works only some of the time - possibly depending on how many variable overrides there are?

{
    name: WRONG
    new_name: right
    value: two

    test_set: {
        test1_long:         something-${value}-${name}-suffix
        test2_long_str:     something-${value}-${name}-suffix
        test3_short:        something-${value}-${name}-suffix
        test4_short_str:    something-${value}-${name}-suffix
    }

    test_set: {
        test1_long:         something-${value}-${new_name}-suffix
        test2_long_str:     something-${value}-legacy-suffix
        test3_short:        x-${new_name}-suffix
        test4_short_str:    x-legacy-suffix
    }
}

Expected:

{
	...
    test_set: {
        test1_long:         something-two-right-suffix
        test2_long_str:     something-two-legacy-suffix
        test3_short:        x-right-suffix
        test4_short_str:    x-legacy-suffix
    }
}

Observed:

{
	...
    test_set: {
        test1_long:         something-two-right-suffix
     	test2_long_str: 	something-two-WRONG-suffix
		test3_short: 		something-two-WRONG-suffix
        test4_short_str:    x-legacy-suffix
    }
}

From a quick code dive, I think this is happening during resolve_substitutions - in order to support self-referential substitutions, overridden substitutions are still evaluated, and they are applied to the resulting object. Depending on if the shadowed fields are evaluated before the final values, the wrong result can be left in the final config object.

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