Skip to content

Commit 8db03c9

Browse files
fix(Variables): Fix too eager nested resolution tracking (#10554)
1 parent 1729e0f commit 8db03c9

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

lib/configuration/variables/resolve.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class VariablesResolver {
338338
valueMeta.variables = valueVariables;
339339
delete valueMeta.sourceValues;
340340
await this.resolveVariables(resolutionBatchId, propertyPath, valueMeta);
341-
await this.resolveInternalResult(resolutionBatchId, propertyPath, valueMeta, --nestTracker);
341+
await this.resolveInternalResult(resolutionBatchId, propertyPath, valueMeta, nestTracker - 1);
342342
return;
343343
}
344344
const valueEntries = (() => {
@@ -353,7 +353,7 @@ class VariablesResolver {
353353
resolutionBatchId,
354354
propertyPath,
355355
propertyValueMeta,
356-
--nestTracker
356+
nestTracker - 1
357357
);
358358
const propertyKeyPathKeys = propertyKeyPath.split('\0');
359359
const targetKey = propertyKeyPathKeys[propertyKeyPathKeys.length - 1];

test/unit/lib/configuration/variables/sources/file.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
2525
addressSupport: '${file(file.json):result}',
2626
jsFunctionResolveVariable: '${file(file-function-variable.js)}',
2727
jsFunctionResolveVariableMissingSource: '${file(file-function-variable-missing-source.js)}',
28+
jsFunctionResolveManyVariables: '${file(file-function-many-variables.js)}',
2829
jsPropertyFunctionResolveVariable: '${file(file-property-function-variable.js):property}',
2930
jsPropertyFunctionResolveVariableMissingSource:
3031
'${file(file-property-function-variable-missing-source.js):property}',
@@ -101,6 +102,9 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
101102
expect(configuration.jsPropertyFunctionResolveVariable).to.deep.equal({
102103
varResult: { result: 'json' },
103104
});
105+
expect(configuration.jsFunctionResolveManyVariables).to.deep.equal({
106+
varResult: { result: ['yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml', 'yml'] },
107+
});
104108
});
105109

106110
it('should resolve variables across address resolution', () => {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = async ({ resolveVariable }) => ({
4+
varResult: await resolveVariable('file(file-function-many-variables.yaml)'),
5+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The resolve nest depth is 10, so we have to resolve at least 10 files to ensure it's not being hit.
2+
result:
3+
- ${file(./file.yml):result}
4+
- ${file(./file.yml):result}
5+
- ${file(./file.yml):result}
6+
- ${file(./file.yml):result}
7+
- ${file(./file.yml):result}
8+
- ${file(./file.yml):result}
9+
- ${file(./file.yml):result}
10+
- ${file(./file.yml):result}
11+
- ${file(./file.yml):result}
12+
- ${file(./file.yml):result}

0 commit comments

Comments
 (0)