You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
W1028 reports both branches of an Fn::If as unreachable when a condition is used twice in one resource #4673
W1028 reports both branches of the same Fn::If as unreachable when a condition
is used at two independent places in one resource and the resource schema has a
conditional (if/then) sub-schema in force.
cfnlint/rules/functions/IfUnsatisfiable.py has no logic. The message comes from fn_if in cfnlint/rules/functions/If.py, which for each branch does
and reports W1028 if that raises Unsatisfiable. When the enclosing walk has
already pinned that condition for the scenario it is enumerating, evolving it to
the other value always contradicts, so the check is a tautology rather than a
question about reachability.
The tell is that both branches get reported. In the template below, ContainerDefinitions[0]'s true branch is called unreachable and the nested LogConfiguration's false branch is called unreachable. AppLogDriver is an
unconstrained String, so both values of HasFireLens are satisfiable and
neither branch is dead.
The two Fn::If are siblings, neither nested inside the other. This is not #3551, where the conditions were layered on the same parameter and the reports
were correct.
What turns it on is the resource schema, not the conditions. RequiresCompatibilities: [FARGATE] selects a conditional sub-schema on AWS::ECS::TaskDefinition; that starts condition-scenario enumeration and the Fn::If nodes get descended again with their condition already pinned. Delete
that one line from the template and both findings go away.
Expected behavior
No W1028 on the template below. A branch should only be reported when it is
unreachable in every satisfiable scenario, not when it disagrees with the one
scenario currently being enumerated.
$ cfn-lint repro.yaml
W1028 ['Fn::If', 1] is not reachable. When setting condition 'HasFireLens' to True from current status False
repro.yaml:16:7
W1028 ['Fn::If', 2] is not reachable. When setting condition 'HasFireLens' to False from current status True
repro.yaml:27:15
Activity
fix(If): base W1028 on forced conditions, not assumptions
fix: scope W1028 to enclosing Fn::If pins (aws-cloudformation#4690)