Repository navigation
fix(E8001): report non-string condition names instead of crashing - #4814
Merged
kddejong merged 1 commit intoOct 21, 2026
Conversation
kddejong
approved these changes
Oct 21, 2026
A Conditions logical ID that parses as a non-string (for example an unquoted YAML integer key) crashed cfn-lint with an unhandled TypeError in Conditions.create_from_instance, before any rule got to run. Skip non-string names when building the condition symbol table, and report them from E8001 with an explicit key-type check (the schema type validation runs non-strict, so propertyNames alone cannot catch them). Also declare the key constraint via propertyNames in the conditions schema. Fixes aws-cloudformation#4813 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
kddejong
force-pushed
the
fix/e8001-non-string-condition-name-4813
branch
from
October 21, 2026 18:17
7c5ac00 to
eac000d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4814 +/- ##
=======================================
Coverage 94.66% 94.67%
=======================================
Files 439 439
Lines 15963 15969 +6
Branches 3091 3095 +4
=======================================
+ Hits 15112 15118 +6
Misses 468 468
Partials 383 383
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
A
Conditionslogical ID that parses as a non-string (for example an unquoted YAML integer key) crashes cfn-lint with an unhandledTypeErrorinstead of being reported as an invalid template:The key reaches
Conditions.create_from_instance, which callsSymbol(name)duringTemplate.__init__, before any rule runs, so E8001 never gets to validate it. CloudFormation rejects the same template (map keys must be strings).Root cause
Two gaps:
Conditions.create_from_instancepasses every condition name tosympy.Symbol, which requires a string, so a non-string name raisesTypeErrorbefore rules run.propertyNames: {"type": "string"}constraint inconditions.jsoncannot catch this on its own, because E8001 validates with non-strict type checking (verified: the check is a no-op there).Fix
context/conditions/_conditions.py: skip non-string condition names when building the condition symbol table (E8001 reports them).rules/conditions/Configuration.py(E8001): explicit key-type check yielding123 is not of type 'string', mirroring the CloudFormation rejection.data/schemas/other/conditions/conditions.json: declare the key constraint viapropertyNames.Tests
test_condition_non_string_names_rejected) and context-level (test_condition_non_string_names_skipped); both verified red pre-fix (theTypeError) and green post-fix.test/unit/rules/conditions+test/unit/module/context: 155 passed.test/unit/rules+test/unit/module: 3021 passed; the 7 failures are pre-existing environment issues (missingpydot/defusedxmletc.), verified identical on pristine upstream main.E8001 123 is not of type 'string'instead of crashing.Fixes #4813