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

fix: nesting-tracking in resolver aborting too eagerly #10554

Merged
merged 2 commits into from Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/configuration/variables/resolve.js
Expand Up @@ -338,7 +338,7 @@ class VariablesResolver {
valueMeta.variables = valueVariables;
delete valueMeta.sourceValues;
await this.resolveVariables(resolutionBatchId, propertyPath, valueMeta);
await this.resolveInternalResult(resolutionBatchId, propertyPath, valueMeta, --nestTracker);
await this.resolveInternalResult(resolutionBatchId, propertyPath, valueMeta, nestTracker - 1);
return;
}
const valueEntries = (() => {
Expand All @@ -353,7 +353,7 @@ class VariablesResolver {
resolutionBatchId,
propertyPath,
propertyValueMeta,
--nestTracker
nestTracker - 1
);
const propertyKeyPathKeys = propertyKeyPath.split('\0');
const targetKey = propertyKeyPathKeys[propertyKeyPathKeys.length - 1];
Expand Down
4 changes: 4 additions & 0 deletions test/unit/lib/configuration/variables/sources/file.test.js
Expand Up @@ -25,6 +25,7 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
addressSupport: '${file(file.json):result}',
jsFunctionResolveVariable: '${file(file-function-variable.js)}',
jsFunctionResolveVariableMissingSource: '${file(file-function-variable-missing-source.js)}',
jsFunctionResolveManyVariables: '${file(file-function-many-variables.js)}',
jsPropertyFunctionResolveVariable: '${file(file-property-function-variable.js):property}',
jsPropertyFunctionResolveVariableMissingSource:
'${file(file-property-function-variable-missing-source.js):property}',
Expand Down Expand Up @@ -101,6 +102,9 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
expect(configuration.jsPropertyFunctionResolveVariable).to.deep.equal({
varResult: { result: 'json' },
});
expect(configuration.jsFunctionResolveManyVariables).to.deep.equal({
varResult: { result: ['yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml'] },
});
});

it('should resolve variables across address resolution', () => {
Expand Down
@@ -0,0 +1,5 @@
'use strict';

module.exports = async ({ resolveVariable }) => ({
varResult: await resolveVariable('file(file-function-many-variables.yaml)'),
});
@@ -0,0 +1,12 @@
# The resolve nest depth is 10, so we have to resolve at least 10 files to ensure it's not being hit.
result:
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}
- ${file(./file.yml):result}