mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fix(Variables): Fix too eager nested resolution tracking (#10554)
This commit is contained in:
parent
1729e0f7bf
commit
8db03c90ff
@ -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];
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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}
|
||||
Loading…
x
Reference in New Issue
Block a user