[aws-stepfunctions]: Nested arrays are not serialized correctly on input #14599
Labels
@aws-cdk/aws-stepfunctions
Related to AWS StepFunctions
bug
This issue is a bug.
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
effort/small
Small work item – less than a day of effort
p1
If part of a Step Function task contains a nested array, part of the array is serialized as an object with the indexes as their string keys.
The issue seems to be inside the
TaskInput.fromObject
call, more specifically in therecurseArray
calls.Reproduction Steps
What did you expect to happen?
This should have been returned:
What actually happened?
It returned this:
Environment
Other
After doing some research I noticed that for deeply nested arrays, every other array ends up mapped to an object. e.g.
Output:
The problem seems to come from this
recurseArray
method:aws-cdk/packages/@aws-cdk/aws-stepfunctions/lib/json-path.ts
Lines 115 to 139 in 7966f8d
Notice that it checks if
value
is an object before checking if it's an array, since arrays are actually considered objects by Javascript, it ends up calling therecurseObject
method.Recommendation:
value
is an array first and call therecurseArray
method instead.This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: