By using AWS re:Post, you agree to the Terms of Use
/AWS StepFunctions: sum() function returns error about not finding path/

AWS StepFunctions: sum() function returns error about not finding path


I have a StepFunction with input:

  "Jobs": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]

and I want the sum of the values in this array. According to the Json-Path docs there should exist a .sum() function for this. When I try it here it even works. So I defined the following Pass state:

"Sum Jobs": {
  "Type": "Pass",
  "Parameters": {
   "Jobs.$": "$.Jobs.sum()"

Nevertheless executions fail with:

"An error occurred while executing the state 'Sum Jobs' (entered at the event id #249). The JSONPath '$.Jobs.sum()' specified for the field 'Jobs.$' could not be found in the input '{\"Jobs\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]}'"
1 Answers

AWS Step Functions does not support functions in the path reference. It uses JSONPath expressions to identify a node, however has the following constraints:

  • You can access object fields using only dot (.) and square bracket ( ) notation.
  • The operators @ .. , : ? * aren't supported.
  • Functions such as length() aren't supported.

This Step Functions documentation that covers this can be found here.

answered 2 months ago
  • This is only valid for Reference Paths: i.e. ItemsPath, ResultPath and OutputPath. However InputPath, Parameters and ResultSelector can use the whole JsonPath syntax. I use filter expressions in these regularly. If you read the docs closely it distinguishes between normal and reference paths in the section you linked to and then states in each section which path is a reference path. For example in the blue box here

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions