Harden CloudFormation variable and Ref resolvers#248
Merged
GrahamCampbell merged 2 commits intomainfrom May 3, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens CloudFormation-backed variable and intrinsic resolvers against optional/missing response arrays, improving robustness and error clarity in AWS pagination scenarios.
Changes:
- Treat missing
StackResourceSummaries,Exports, andOutputsfields as empty arrays to avoid runtime crashes. - Improve the user-facing
Refresolution error message grammar. - Add unit coverage for pagination where intermediate pages omit optional arrays, plus coverage for stacks with no outputs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/plugins/aws/utils/resolve-cf-ref-value.js |
Avoids crashing when StackResourceSummaries is omitted; updates Ref error message. |
lib/plugins/aws/utils/resolve-cf-import-value.js |
Avoids crashing when Exports is omitted during listExports pagination. |
lib/configuration/variables/sources/instance-dependent/get-cf.js |
Treats missing Outputs as an empty list when resolving ${cf:...} variables. |
test/unit/lib/plugins/aws/utils/resolve-cf-ref-value.test.js |
Adds pagination coverage for pages that omit StackResourceSummaries and verifies updated error message. |
test/unit/lib/plugins/aws/utils/resolve-cf-import-value.test.js |
Adds pagination coverage for pages that omit Exports. |
test/unit/lib/configuration/variables/sources/instance-dependent/get-cf.test.js |
Adds coverage for stacks that return no Outputs. |
Comments suppressed due to low confidence (1)
lib/plugins/aws/utils/resolve-cf-import-value.js:11
- When continuing pagination, the recursive call replaces
sdkParamswith{ NextToken: ... }, which drops any other params the caller may have provided. Consider preserving existing params when paginating (e.g., mergeNextTokeninto the current params) so pagination remains correct if additional request params are ever introduced/used.
const targetExportMeta = (result.Exports || []).find((exportMeta) => exportMeta.Name === name);
if (targetExportMeta) return targetExportMeta.Value;
if (result.NextToken) {
return resolveCfImportValue(provider, name, { NextToken: result.NextToken });
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests