Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(@aws-cdk/aws-stepfunction-tasks): Unnecessary validation of field "Headers" in CallApiGatewayRestApiEndpoint #14181

Closed
paraspra opened this issue Apr 14, 2021 · 3 comments · Fixed by #18595
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@paraspra
Copy link

The validation of Header property in constructor of CallApiGatewayRestApiEndpoint is unnecessary as StepFunction UI (i.e Amazon States Language) allows apigateway:invoke.waitForTaskToken without "Header" property.

Also, as per HttpHeaderDeserializer in StepFunctionsHttpConnectors , Headers property is deserialized as Map<String, List<String>> . Constructing this structure in CDK with JsonPath is currently not possible.

This validation is enforcing to add headers: TaskInput.fromObject({ TaskToken: JsonPath.taskToken) in CallApiGatewayRestApiEndpoint props. When task with this configuration is deployed and run in AWS StepFunction it throws errror parameter could not be used to start the Task: [The value of the field 'Headers' has an invalid format]"

Reproduction Steps

create Task, and deploy it. Try to run this stepFunction.

const task = new CallApiGatewayRestApiEndpoint(this, title, {
            api: restAPI,
            method: HttpMethod.PUT,
            stageName: apiStage,
            requestBody: TaskInput.fromObject({})
            authType: AuthType.IAM_ROLE,
            apiPath: apiPath,
            resultPath: resultPath,
            headers: TaskInput.fromObject({ TaskToken: JsonPath.taskToken),
            integrationPattern: IntegrationPattern.WAIT_FOR_TASK_TOKEN
          })

What did you expect to happen?

Task should make a call to the ApiGateway

What actually happened?

Exception during task execution
parameter could not be used to start the Task: [The value of the field 'Headers' has an invalid format]"

Environment

  • CDK CLI Version : 1.96.0
  • Framework Version: 1.96.0
  • Node.js Version: v14.6.0
  • OS : MacOS
  • Language (Version): TypeScript

Other


This is 🐛 Bug Report

@paraspra paraspra added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 14, 2021
@shivlaks shivlaks added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 24, 2021
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 21, 2022

From this ticket: #14184, apparently you need to put States.Array() around the task token:

            headers: TaskInput.fromObject({ TaskToken: `States.Array(${JsonPath.taskToken})` }),

If you find that hard to read, it's the same as:

            headers: TaskInput.fromObject({ TaskToken: 'States.Array(' + JsonPath.taskToken +')' }),

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 21, 2022

Nevermind, this does not work.

rix0rrr added a commit that referenced this issue Jan 21, 2022
…teway

To pass the Task Token in headers to an API Gateway, the token must
be wrapped in an array (because that's the value type of headers).

Because JSONPath evaluation needs to happen to resolve the token,
we need to use the `States.Array()` function in a `JsonPathToken`
to properly resolve this. However, doing that makes the existing
validation code fail the validation checking that you are passing
the task token somewhere.

Add convenience methods for the intrinsics, and update the checker
to also find paths referenced inside intrinsic functions.

Fixes #14184, fixes #14181.
@mergify mergify bot closed this as completed in #18595 Jan 25, 2022
mergify bot pushed a commit that referenced this issue Jan 25, 2022
…teway (#18595)

To pass the Task Token in headers to an API Gateway, the token must
be wrapped in an array (because that's the value type of headers).

Because JSONPath evaluation needs to happen to resolve the token,
we need to use the `States.Array()` function in a `JsonPathToken`
to properly resolve this. However, doing that makes the existing
validation code fail the validation checking that you are passing
the task token somewhere.

Add convenience methods for the intrinsics, and update the checker
to also find paths referenced inside intrinsic functions.

Fixes #14184, fixes #14181.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

LukvonStrom pushed a commit to LukvonStrom/aws-cdk that referenced this issue Jan 26, 2022
…teway (aws#18595)

To pass the Task Token in headers to an API Gateway, the token must
be wrapped in an array (because that's the value type of headers).

Because JSONPath evaluation needs to happen to resolve the token,
we need to use the `States.Array()` function in a `JsonPathToken`
to properly resolve this. However, doing that makes the existing
validation code fail the validation checking that you are passing
the task token somewhere.

Add convenience methods for the intrinsics, and update the checker
to also find paths referenced inside intrinsic functions.

Fixes aws#14184, fixes aws#14181.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…teway (aws#18595)

To pass the Task Token in headers to an API Gateway, the token must
be wrapped in an array (because that's the value type of headers).

Because JSONPath evaluation needs to happen to resolve the token,
we need to use the `States.Array()` function in a `JsonPathToken`
to properly resolve this. However, doing that makes the existing
validation code fail the validation checking that you are passing
the task token somewhere.

Add convenience methods for the intrinsics, and update the checker
to also find paths referenced inside intrinsic functions.

Fixes aws#14184, fixes aws#14181.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants