Skip to content

Commit

Permalink
fix(Variables): Ensure to report only unrecognized sources
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jun 9, 2021
1 parent 93b89fc commit 98701f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/serverless.js
Expand Up @@ -580,6 +580,7 @@ const processSpanPromise = (async () => {
// Report unrecognized variable sources found in variables configured in service config
const unresolvedSources =
require('../lib/configuration/variables/resolve-unresolved-source-types')(variablesMeta);
const recognizedSourceNames = new Set(Object.keys(resolverConfiguration.sources));
if (!(configuration.variablesResolutionMode >= 20210326)) {
const legacyCfVarPropertyPaths = new Set();
const legacySsmVarPropertyPaths = new Set();
Expand Down Expand Up @@ -619,7 +620,7 @@ const processSpanPromise = (async () => {
{ serviceConfig: configuration }
);
}
const recognizedSourceNames = new Set(Object.keys(resolverConfiguration.sources));

const unrecognizedSourceNames = Array.from(unresolvedSources.keys()).filter(
(sourceName) => !recognizedSourceNames.has(sourceName)
);
Expand All @@ -636,10 +637,13 @@ const processSpanPromise = (async () => {
);
}
} else {
const unrecognizedSourceNames = Array.from(unresolvedSources.keys()).filter(
(sourceName) => !recognizedSourceNames.has(sourceName)
);
throw new ServerlessError(
`Approached unrecognized configuration variable sources: "${Array.from(
unresolvedSources.keys()
).join('", "')}"`,
`Approached unrecognized configuration variable sources: "${unrecognizedSourceNames.join(
'", "'
)}"`,
'UNRECOGNIZED_VARIABLE_SOURCES'
);
}
Expand Down

0 comments on commit 98701f3

Please sign in to comment.