title: AWS Step Function: Function .length() returned error in variable field in Choice state
body: <p>I have a Choice state in AWS Step Function that would compare an array's length from Input and make decision to go next state.</p>
  <p>However, the <code>length()</code> function, to get the array's length, returned an error:</p>
  <blockquote>
  <p>{<br />
  &quot;error&quot;: &quot;States.Runtime&quot;,<br />
  &quot;cause&quot;: &quot;An error occurred while executing the state    'CheckItemsCountState' (entered at the event id #18). Invalid path '$.Metadata[2].Items.length()': The choice state's condition path references an invalid value.&quot;</p>
  <p>}</p>
  </blockquote>
  <p>The Choice state's definition is as below:</p>
  <pre><code>     &quot;CheckItemsCountState&quot;:{  
           &quot;Type&quot;: &quot;Choice&quot;,
           &quot;InputPath&quot;: &quot;$&quot;,
           &quot;OutputPath&quot;: &quot;$&quot;,
           &quot;Default&quot;: &quot;NoItemsState&quot;,
           &quot;Choices&quot;:[  
              {  
                 &quot;Variable&quot;: &quot;$.Metadata[2].Items.length()&quot;,
                 &quot;NumericGreaterThan&quot;: 0,
                 &quot;Next&quot;: &quot;ProcessState&quot;
              }
           ]
        },
  </code></pre>
  <p>The state is connected some other state that returns a JSON. The JSON is as below:</p>
  <pre><code>{
    &quot;Metadata&quot;: [
      {
        &quot;foo&quot;: &quot;name&quot;
      },
      {
        &quot;Status&quot;: &quot;COMPLETED&quot;
      },
      {
        &quot;Items&quot;: []
      }
    ]
  }
  </code></pre>
  <p>So I was trying to get the length of <code>Items</code> in <code>Metadata[2]</code> and make comparison if the value is greater than 0.</p>
  <p>I have tried to validate the JsonPath <code>$.Metadata[2].Items.length()</code> in this <a href="http://jsonpath.herokuapp.com" rel="noreferrer">website</a> and it returns 0.</p>
  <p>I am not sure if I've missed anything. I couldn't find any information in AWS Step Function's docs or example on using function in jsonpath.</p>
  <p>I would appreciate for any help. Thank you!</p>