I have a select state in AWS Step Function that compares the length of an array with Input and decides to go to the next state.
However, the function length()returned an error to get the length of the array:
{
"error": "States.Runtime",
"reason": "An error occurred while executing the" CheckItemsCountState "state (entered in event ID No. 18). Invalid path" $ .Metadata [2] .Items.length () ": the choice state state path refers to an invalid value. "
}
The determination of the selection state is as follows:
"CheckItemsCountState":{
"Type": "Choice",
"InputPath": "$",
"OutputPath": "$",
"Default": "NoItemsState",
"Choices":[
{
"Variable": "$.Metadata[2].Items.length()",
"NumericGreaterThan": 0,
"Next": "ProcessState"
}
]
},
- , JSON. JSON :
{
"Metadata": [
{
"foo": "name"
},
{
"Status": "COMPLETED"
},
{
"Items": []
}
]
}
, Items Metadata[2] , 0.
JsonPath $.Metadata[2].Items.length() - 0.
, - . - AWS Step Function jsonpath.
. !