fix(stepfunctions): cannot use intrinsic functions in Fail state #30193
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.
Issue # (if applicable)
Closes #30063
Reason for this change
In the Fail state, we can specify intrinsic functions and json paths as the CausePath and ErrorPath properties.
Currently, however, specifying intrinsic functions as a string will result in an error.
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html
Description of changes
The value passed to the
renderJsonPath
function is expected to be a string starting with$
if it is not a token.However, if you pass intrinsic functions as strings to the CausePath and ErrorPath properties, they will never start with
$
.Therefore, I fixed not to call the
renderJsonPath
function if the intrinsic functions are specified as strings.Another change was the addition of validation since error and errorPath, cause and causePath cannot be specified simultaneously.
Description of how you validated changes
I added unit tests to verify that passing intrinsic functions as strings do not cause an error.
Tests were also added to verify that errors occur when errors and paths are specified at the same time and when cause and cause paths are specified at the same time.
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html#:~:text=%2C%20and%20States.UUID.-,Important,-You%20can%20specify%20either%20Cause
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html#:~:text=%2C%20and%20States.UUID.-,Important,-You%20can%20specify%20either%20Error
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license