- Newest
- Most votes
- Most comments
- Remove the "Output" field from both the main task and the "Catch" block.
- Add a "ResultPath" field to the main task set to null.
- Add a "ResultPath" field to the "Catch" block set to null.
Here's the modified task definition:
"GetObject": { "Type": "Task", "Arguments": { "Bucket": "bucketname", "Key": "{% 'images/accounts/' & $accountId & '.json' %}" }, "Resource": "arn:aws:states:::aws-sdk:s3:getObject", "Next": "update or create", "ResultPath": null, "Assign": { "existingImages": "{% $parse($states.result.Body) %}" }, "Catch": [ { "ErrorEquals": [ "S3.NoSuchKeyException" ], "Next": "update or create", "ResultPath": null, "Assign": { "existingImages": [] } } ] }
By setting "ResultPath" to null in both the main task and the "Catch" block, you're telling Step Functions to discard the result of the S3 GetObject operation (or the error in case of a failure) and keep the input as the output. This ensures that $states.input is passed along to the next state, regardless of whether the S3 object exists or not.
The "Assign" operations will still work as expected, setting the existingImages variable in both cases. This approach should resolve your issue and allow the step input to be passed along as the output, while still assigning the correct value to existingImages based on whether the S3 object exists or not.
Sources
Why Does S3 Return 403 Instead of 404 When the Object Doesn’t Exist? | AWS re:Post
Learn the basics of Amazon S3 with an AWS SDK - Amazon Simple Storage Service
I think your code is assigning the value correctly but you are not using the value. The assigned value will be available in the next step. Can you confirm if the the value is appearing correctly or not in the next step.
Relevant content
- AWS OFFICIALUpdated 3 months ago

Honestly a pretty high-quality generative response! But "field 'ResultPath' is only supported for the 'JSONPath' QueryLanguage" and (as you can see from the {% %} designators) this step is using JSONata.