Repository navigation
fix(resolver): stop false circular file references from leaked origins - #85
Merged
Merged
Conversation
A value's next origin (the file its text now belongs to) leaked in two ways,
so a later file() ref in the value looked like it came from that same file:
- A value mixing file() with other text (sl-${file(./mod.cjs):name}-${env:X})
took the file's origin. A ${self:} ref to it then carried that origin and
re-resolving the embedded file() reported mod.cjs -> mod.cjs. populateValue
now keeps the prior origin unless the value is one whole reference.
- Fallback short-circuiting probes plain items up front. With two failing
links before a file() link that is not last, the file() probe ran, its value
went unused, but its origin stuck, so the next pass reported
config.json -> config.json. Only a probe whose value replaces its list keeps
its origin now.
Real cycles behind mixed values and fallback chains are still detected.
Validation: configorama npm test (8/8, 27/27, 863/863, 1810/1810), typecheck,
configx tests. New tests fail on 1.5.0 in async and sync APIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Fixes two false
Circular file reference detectederrors that 1.5.0 throws and 1.4.9 did not.Root cause
A value's
nextOrigin(the file its text now belongs to) leaked onto values that did not wholly come from that file. The next pass then resolved afile()ref in the value from that file's lineage and reported a cycle.file()set mod.cjs asb's next origin.xresolved${self:b}to${deep:0}, and resolving that deep value carried mod.cjs ontox, whichassignPropertiesstored for pathx. Re-resolving the embeddedfile()reportedstack.yml -> mod.cjs -> mod.cjs.Fix:
populateValuekeeps the prior origin unless the value is one whole reference.${env:A, ${env:B}, ...}).shortCircuitFallbacksprobes the list's plain items up front, so it resolved thefile()item too (index 2, after the nested match at index 1). That value was thrown away, but its origin stayed on the valueObject. The next pass reportedconfig.json -> config.json. It only shows up with two or more failing links before afile()link that is not last. The parent-dir walk-up is not needed to trigger it.Fix: after probing, the origin goes back to what it was before the probe. Only a probe whose value replaces its list keeps its origin.
A fallback list that is a whole reference, and whose nested item wins, still passes that item's origin on. So a file object with relative
file()refs inside a fallback still resolves next to that file.Tests
In
tests/reliability/fileOrigins.test.js, each test runs through both the async and sync APIs:file()+env:valueconfig.json, a local file, and afile()followed by anotherfile()The first two fail on master. The full suite passes:
npm test(8/8, 27/27, 863/863, 1810/1810), plustypecheckand the configx tests.Real-world check (no AWS): SaaSLayer
services/permissions-service/ui/stack.yml(sync and async) andservices/user-service/stack.yml, standalone without slug/prefix env. Both fail with a circular error on 1.5.0 and resolve on this branch.