Skip to content

RunLambdaTask with outputPath not working  #7709

@eikeon

Description

@eikeon

outputPath when used with RunLambdaTask is not working as documented. In the step functions overview under Lambda example

"The following snippet invokes a Lambda and sets the task output to only include the Lambda function response."

new sfn.Task(this, 'Invoke and set function response as task output', {
  task: new tasks.RunLambdaTask(myLambda, {
    payload: sfn.TaskInput.fromDataAt('$'),
  }),
  outputPath: '$.Payload',
});

Reproduction Steps

Starting from a working tasks.InvokeFunction:

<!--
minimal amount of code that causes the bug (if possible) or a reference:
-->

         const getObject = new sfn.Task(this, "Get Object", {
-            task: new tasks.RunLambdaTask(getObjectLambda, {}),
-            outputPath: "$.Payload",
+            task: new tasks.InvokeFunction(getObjectLambda, {}),
             resultPath: "$.GetObjectResult",
         });

Also tried outputPath: "$.output.Payload" with same result.

Error Log

TaskSucceeded with:

{
  "resourceType": "lambda",
  "resource": "invoke",
  "output": {
    "ExecutedVersion": "$LATEST",
    "Payload": {
      "Done": true,
      "Next": null,
      "BitsFetched": 0
    },
    "SdkHttpMetadata": {
      "HttpHeaders": {
        "Connection": "keep-alive",
        "Content-Length": "41",
        "Content-Type": "application/json",
        "Date": "Thu, 30 Apr 2020 00:36:36 GMT",
        "X-Amz-Executed-Version": "$LATEST",
        "x-amzn-Remapped-Content-Length": "0",
        "x-amzn-RequestId": "f1e1c5df-4740-4389-8230-2c495c5cd829",
        "X-Amzn-Trace-Id": "root=1-5eaa1d94-16cf39fcb6ea5d8bb11bd635;sampled=0"
      },
      "HttpStatusCode": 200
    },
    "SdkResponseMetadata": {
      "RequestId": "f1e1c5df-4740-4389-8230-2c495c5cd829"
    },
    "StatusCode": 200
  }
}

followed by `ExecutionFailed` with:

```json
{
  "error": "States.Runtime",
  "cause": "An error occurred while executing the state 'Get Object' (entered at the event id #2). Invalid path '$.Payload' : No results for path: $['Payload']"
}

{



### Environment

  - **CLI Version      :** 1.36.1
  - **Framework Version:** 1.36.1
  - **OS               :** macOS Catalina 10.15.5 Beta (19F62f)
  - **Language         :** Typescript

### Other

<!-- e.g. detailed explanation, stacktraces, related issues, suggestions on how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc -->




--- 

This is :bug: Bug Report

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions