Repository navigation
fix(rules): stringify E3601 path segments so array indices do not crash message formatting - #4782
Merged
kddejong merged 1 commit intoOct 21, 2026
Conversation
kddejong
approved these changes
Oct 21, 2026
…sh message formatting E3601's _fix_message joined err.path with '/'.join(err.path), but err.path is a jsonschema deque that holds integer indices when the error sits inside an array (for example a Catch entry at States/T/Catch/0/ErrorEquals). The join raised TypeError, which the dispatcher reported as E1101, and every other E3601 finding on the same state machine was lost. Stringify each path element before joining, so integer indices render as 'States/T/Catch/0/ErrorEquals' and all findings surface as E3601. Adds a regression test covering an error inside Catch[0] in a JSON-string DefinitionString (fails with TypeError before the fix). Fixes aws-cloudformation#4775 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
kddejong
force-pushed
the
fix-4775-e3601-array-path-crash
branch
from
October 21, 2026 00:01
ee2595f to
dbab1cb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4782 +/- ##
=======================================
Coverage 94.70% 94.70%
=======================================
Files 439 439
Lines 15895 15895
Branches 3078 3078
=======================================
Hits 15053 15053
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.
Summary
Fixes #4775.
When a Step Functions
DefinitionStringcontains a validation error whose path crosses a JSON array (for example anErrorEqualstype error inside aCatchentry), E3601's_fix_messagecrashed and the cfn-lint dispatcher reported it as E1101. Worse, every other E3601 finding on that state machine was silently lost with the crash: a template with three real errors reported only the E1101.Root cause
In
src/cfnlint/rules/resources/stepfunctions/StateMachineDefinition.py,_fix_messagebuilt the message suffix with'/'.join(err.path).err.pathis a jsonschema deque that holds integer indices for array positions, so the join raisedTypeError: sequence item 3: expected str instance, int foundfor any path likeStates/T/Catch/0/ErrorEquals. This only affected the string form, because_fix_messageruns only when the definition was parsed fromDefinitionString(add_path_to_message=True).Fix
Stringify each path element before joining:
'/'.join(str(p) for p in err.path). Integer indices now render literally, so the suffix readsat 'States/T/Catch/0/ErrorEquals'and all findings surface as E3601.Tests
test_fix_message_with_array_index_in_pathintest/unit/rules/resources/stepfunctions/test_state_machine_definition.py: a JSON-stringDefinitionStringwith the issue's template-B shape (error insideCatch[0]plus a badStartAtand an invalid stateType). It asserts all three E3601 findings surface, the path suffix renders with the array index, and no E1101 appears. Red/green verified: the test fails withTypeErroron the unpatched code and passes with the fix.ruff checkandruff formatclean on both changed files.E3601 'States.ALL' is not of type 'array' at 'States/T/Catch/0/ErrorEquals'; B reports that error plus the two previously hidden findings (StartAttarget, invalid stateType); no E1101.Known limits
None beyond the pre-existing behavior: message suffixes were already best-effort path annotations for the string form. The object form (
Definition) was never affected and is unchanged.