#256 - Process substitution overrides in order #257
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing #256 - and a small radius around it.
The Scenario
Using hocon in a larger system where this came up.
During substitution & replacement, the following happened:
Starting queue had these substitutions: [${lookup}(parent), ${name}(parent), ${lookup}(child)]
${lookup}(parent)
, the result value still had -${name}, so this substitution stays in the set to re-process, and enqueues ${name}(2) at the end of the list.${name}(parent)
- this produces a static result string, and is removed.${lookup}(child)
- this produces a static result string, and is removed.(that's all the substitutions, so the loop restarts)
${lookup}(parent)
- overwrites step 3. No overrides remain, so is removed.${name}(2)
- also overwrites step 3. No overrides remain, so is removed.Proposed Fix:
When looking at a substitution, first check if it has a parent override, and if that parent is active in the substitution list. Wait for all parents to complete before processing the substitution.
This caused two test failures:
g: ${?missing1} ${?missing2}
would be alternatively added or removed from config as the substitutions processed. This diff changes _do_substitute to only write/add a value if the value is not None.Testing
^ NamedTemporaryFile does not work on Windows (python.org) - I'll try to kick the tires in docker if there's traction for landing this.