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

Consistently resolve transitive substitutions #37

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

rtphubeny
Copy link

The existing implementation of substitution resolution inconsistently resolves transitive substitutions of Object contents because the Object is an unordered map. If a dependent is evaluated before the dependency, the dependent is not properly resolved.

For example:

{
  a: 5,
  b: ${a},
  c: ${b},
}

c will correctly resolve to 5 if b has been resolved first. However, if c is resolved first, c is evaluated to ${a}.

According to HOCON docs,

In general, in resolving a substitution the implementation must:

  • lazy-evaluate the substitution target so there's no
    "circularity by side effect"
  • "look forward" and use the final value for the path
    specified in the substitution
  • if a cycle results, the implementation must "look back"
    in the merge stack to try to resolve the cycle
  • if neither lazy evaluation nor "looking only backward" resolves
    a cycle, the substitution is missing which is an error unless
    the ${?foo} optional-substitution syntax was used.

This pull request does not specifically implement a "forward" or "backward looking" solution, but it does evaluate the graph for cycles and improves substitution resolution consistency.

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Base: 95.34% // Head: 95.39% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (e6dc29c) compared to base (67c3b38).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   95.34%   95.39%   +0.05%     
==========================================
  Files           3        3              
  Lines         773      782       +9     
==========================================
+ Hits          737      746       +9     
  Misses         24       24              
  Partials       12       12              
Impacted Files Coverage Δ
parser.go 95.88% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rebecca-hubeny-okcupid
Copy link

@gurkankaymak can you please take a look at this pull request when you have the time?

@gurkankaymak gurkankaymak merged commit 6ee0f72 into gurkankaymak:master Feb 13, 2023
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

Successfully merging this pull request may close these issues.

3 participants