Skip to content

Fix crash when the template Metadata is not an object - #4807

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
Neg23:fix-non-object-template-metadata
Oct 21, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
Neg23:fix-non-object-template-metadata

Conversation

@Neg23

@Neg23 Neg23 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #4768

Issue #, if available: #4768

Description of changes:

  • TemplateArgs.set_template_args now treats a non-object top-level Metadata (string, null, list) or a non-object Metadata.cfn-lint as having no cfn-lint config, instead of raising AttributeError.
  • Because cfn-lint no longer crashes, E4002 now reports the invalid value, e.g. 'hello' is not of type 'object'.
  • Added a unit test with four cases. They fail without the fix and pass with it.

Related: #4784 fixes the same crash shape for resource-level Metadata (#4769).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kddejong
kddejong force-pushed the fix-non-object-template-metadata branch from ab3d272 to 389b3ee Compare October 21, 2026 17:17
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (27243cb) to head (389b3ee).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4807   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         439      439           
  Lines       15908    15910    +2     
  Branches     3079     3079           
=======================================
+ Hits        15069    15071    +2     
  Misses        458      458           
  Partials      381      381           
Flag Coverage Δ
unittests 94.72% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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 7fbb68c into aws-cloudformation:main Oct 21, 2026
21 checks passed
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.

E4002: a non-object top-level Metadata crashes cfn-lint

2 participants