fix(Variables): Fix too eager nested resolution tracking (#10554)

This commit is contained in:
Steven Noorbergen 2022-01-24 14:03:32 +01:00 committed by GitHub
parent 1729e0f7bf
commit 8db03c90ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View File

@ -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 = (() => {
@ -353,7 +353,7 @@ class VariablesResolver {
resolutionBatchId,
propertyPath,
propertyValueMeta,
--nestTracker
nestTracker - 1
);
const propertyKeyPathKeys = propertyKeyPath.split('\0');
const targetKey = propertyKeyPathKeys[propertyKeyPathKeys.length - 1];

View File

@ -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}',
@ -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', () => {

View File

@ -0,0 +1,5 @@
'use strict';
module.exports = async ({ resolveVariable }) => ({
varResult: await resolveVariable('file(file-function-many-variables.yaml)'),
});

View File

@ -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}