Repository navigation
fix: Skip E3700 first-stage check for conditional stage entries - #4701
Merged
Merged
Conversation
A CodePipeline Stages entry can be an Fn::If that resolves to AWS::NoValue. When earlier entries collapse to NoValue, a stage's list index no longer reflects its realized order, so _is_first_stage misclassified a conditional source stage past index 0 and E3700 fired a false positive on its 'Source' category. Return None (no determination) when a stage's index is immediately followed by an Fn::If in the path, since the order can't be inferred. Plain stages and whole-list Fn::If wrappers are unaffected. aws-cloudformation#4672
deque elements are typed Any, so 'return path[i] == 0' returned Any from a function declared to return bool | None. Wrap in bool().
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4701 +/- ##
=======================================
Coverage 94.66% 94.66%
=======================================
Files 434 434
Lines 15561 15561
Branches 3019 3019
=======================================
Hits 14731 14731
Misses 453 453
Partials 377 377
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 #4672
Problem
E3700treats a stage's index in theStageslist as its order. When aStagesentry is anFn::Ifthat can resolve toAWS::NoValue, index and realized order diverge: once an earlier conditional stage collapses toNoValue, a later conditional source stage becomes the first realized stage but still carries a non-zero list index._is_first_stagereturnedFalsefor it and theSourcecategory was rejected — a false positive.The runtime path for a conditional stage entry is
Stages / <index> / Fn::If / <branch> / Actions / ...(the list index precedesFn::If), so the old loop returned on the index before accounting for the condition.Fix
When a stage's list index is immediately followed by
Fn::Ifin the path, the entry is conditional and its realized order can't be inferred, so_is_first_stagenow returnsNone(no determination), per the reporter's suggestion. Plain stages and whole-listFn::Ifwrappers (Stages / Fn::If / branch / index) are unchanged, preserving existing true positives.Testing
Source) still flags E3700.