Skip to content

Add W1053: Warn on dynamic references with spaces#4412

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4171
Mar 25, 2026
Merged

Add W1053: Warn on dynamic references with spaces#4412
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4171

Conversation

@kddejong
Copy link
Copy Markdown
Contributor

Summary

Dynamic references like {{ resolve:ssm:Param }} with spaces between {{ and resolve are silently treated as literal strings by CloudFormation instead of being resolved. This adds W1053, a warning rule to detect this common mistake.

Testing

Confirmed against CloudFormation directly:

  • {{resolve:ssm:CfnLintTest4171}} → resolves to the parameter value ✅
  • {{ resolve:ssm:CfnLintTest4171 }} → left as a literal string, not resolved ❌

Changes

  • src/cfnlint/helpers.py — Added REGEX_DYN_REF_SPACES regex
  • src/cfnlint/jsonschema/_filter.py — Detect spaced dynamic references in the filter
  • src/cfnlint/rules/jsonschema/JsonSchema.py — Register dynamicReferenceSpaces keyword
  • src/cfnlint/rules/functions/DynamicReferenceSpaces.py — New W1053 rule
  • Unit tests for the rule and filter
  • Integration test with end-to-end validation

Fixes #4171

Dynamic references like '{{ resolve:ssm:Param }}' with spaces between
'{{' and 'resolve' are silently treated as literal strings by
CloudFormation instead of being resolved. This adds a warning rule
to detect this common mistake.

Fixes aws-cloudformation#4171
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (0bbabc9) to head (a2b1aff).
⚠️ Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4412      +/-   ##
==========================================
- Coverage   93.54%   93.45%   -0.09%     
==========================================
  Files         418      424       +6     
  Lines       14145    14365     +220     
  Branches     2817     2866      +49     
==========================================
+ Hits        13232    13425     +193     
- Misses        567      582      +15     
- Partials      346      358      +12     
Flag Coverage Δ
unittests 93.45% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong kddejong merged commit f7e734a into aws-cloudformation:main Mar 25, 2026
17 of 18 checks passed
@kddejong kddejong deleted the fix/issue/4171 branch March 25, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSM Parameter shorthand incorrect syntax still not detected

1 participant