Repository navigation
fix(rules): don't crash when a resource or output condition can never be true - #4786
Merged
kddejong merged 1 commit intoOct 21, 2026
Conversation
kddejong
approved these changes
Oct 20, 2026
…on can never be true Properties.validate pinned the resource's own condition to True through context.conditions.evolve(), and outputs/Value.py did the same for outputs. When that condition is unsatisfiable (for example X and not X over two identical condition bodies), evolve raised Unsatisfiable and nothing caught it, so the cfnLint keyword catch-all reported it as an E3001 Exception raised while validating finding and the rest of that resource's validation was skipped. Catch Unsatisfiable at both pins and continue validation without the impossible pin, consistent with how a lone statically false condition used directly already behaves (E3002 on the gated resource, no crash). Adds regression tests for the resource shape and the output shape (both fail with Unsatisfiable before the fix). Fixes aws-cloudformation#4785 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
kddejong
force-pushed
the
varshith/cfn-lint-4785-unsatisfiable-condition
branch
from
October 20, 2026 23:58
5abfdf3 to
8c818e1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4786 +/- ##
=======================================
Coverage 94.70% 94.70%
=======================================
Files 439 439
Lines 15895 15905 +10
Branches 3078 3078
=======================================
+ Hits 15053 15063 +10
Misses 459 459
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.
Fixes #4785
Root cause
Properties.validate(E3002 family) pins the resource's ownConditiontoTruethroughcontext.conditions.evolve(...)before validating its properties, andoutputs/Value.py(E6101) does the same for outputs. When that condition can never be true (for exampleX and not Xover two identical condition bodies),evolveraisesUnsatisfiableand nothing catches it. ThecfnLintkeyword catch-all then reports it as anE3001 Exception "When setting condition '...' to True" raised while validating 'cfnLint'finding, and the rest of that resource's (or output's) validation is skipped, hiding real findings.Fix
Catch
Unsatisfiableat both pins and continue validation without the impossible pin. This is consistent with how cfn-lint already handles a lone statically false condition used directly on a resource: the resource is still validated (E3002 fires on its bad properties) instead of crashing. It follows the existing convention used by the otherconditions.evolvecall sites (_resolvers_cfn.py,rules/functions/If.py,template.py, ...), which all catchUnsatisfiable.Tests
ControlwhileGatedgot the crash; template D reported the output-side exception. After the fix: no exceptions; template C reports E3002 on bothControlandGated(the issue's expected behavior); templates A, B, D report only the expected W8003s. A lone named always-false condition crashed the same way before the fix and is also fixed.test_validate_with_unsatisfiable_condition(resources/properties) andtest_output_value_with_unsatisfiable_condition(outputs). Both fail withUnsatisfiableraised before the fix and pass after.test/unit/moduleare pre-existing environment issues (missingpydot/defusedxmlmodules, provider-schema content drift), confirmed identical on pristineupstream/main. Ruff check and format clean.Caveats
Value.pypins any truthyConditionvalue (not just strings); that pre-existing behavior is unchanged.