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

fix(stepfunctions): non-object arguments to recurseObject are incorrectly treated as objects #14631

Merged
merged 4 commits into from
Jul 23, 2021

Conversation

marciocarmona
Copy link
Contributor

This doesn't actually fix the issue #12935 as currently the Json paths won't be resolved for Lambda steps where the Resource is the Lambda ARN and not arn:aws:states:::lambda:invoke, but it at least fixes the issue for Text inputs when payloadResponseOnly: true and will avoid the same error from happening again if the recurseObject is called with a value that's not an object.

Ideally the TaskInput.value field should be changed to { [key: string]: any } | string here to ensure the type check when sending the value to methods like FieldUtils.renderObject:
https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-stepfunctions/lib/input.ts#L65

Or even better the TaskInput should be made generic like:

export class TaskInput<T extends InputType> {
  ...
  private constructor(public readonly type: T, public readonly value: ValueType[T]) {}
}

type ValueType = {
  [InputType.OBJECT]: { [key: string]: any },
  [InputType.TEXT]: string
}

However, any of the changes above wouldn't be backwards compatible and could break not only internal references in the aws-cdk but also on any customer packages using the CDK.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented May 11, 2021

@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label May 11, 2021
@marciocarmona marciocarmona changed the title fix(stepfunctions) checking recurseObject argument type to ensure it's really an object fix(stepfunctions): checking recurseObject argument type to ensure it's really an object May 11, 2021
BenChaimberg
BenChaimberg previously approved these changes Jul 23, 2021
@BenChaimberg BenChaimberg added the pr/do-not-merge This PR should not be merged at this time. label Jul 23, 2021
@BenChaimberg BenChaimberg changed the title fix(stepfunctions): checking recurseObject argument type to ensure it's really an object fix(stepfunctions): non-object arguments to recurseObject are returned immediately Jul 23, 2021
@BenChaimberg BenChaimberg changed the title fix(stepfunctions): non-object arguments to recurseObject are returned immediately fix(stepfunctions): non-object arguments to recurseObject are incorrectly treated as objects Jul 23, 2021
BenChaimberg
BenChaimberg previously approved these changes Jul 23, 2021
@BenChaimberg BenChaimberg removed the pr/do-not-merge This PR should not be merged at this time. label Jul 23, 2021
@mergify
Copy link
Contributor

mergify bot commented Jul 23, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 98928d6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit e133bca into aws:master Jul 23, 2021
@mergify
Copy link
Contributor

mergify bot commented Jul 23, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Aug 3, 2021
…ctly treated as objects (aws#14631)

This doesn't actually fix the issue aws#12935 as currently the Json paths won't be resolved for Lambda steps where the `Resource` is the Lambda ARN and not `arn:aws:states:::lambda:invoke`, but it at least fixes the issue for Text inputs when `payloadResponseOnly: true` and will avoid the same error from happening again if the `recurseObject` is called with a value that's not an object.

Ideally the `TaskInput.value` field should be changed to `{ [key: string]: any } | string` here to ensure the type check when sending the value to methods like `FieldUtils.renderObject`:
https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-stepfunctions/lib/input.ts#L65

Or even better the `TaskInput` should be made generic like:
```
export class TaskInput<T extends InputType> {
  ...
  private constructor(public readonly type: T, public readonly value: ValueType[T]) {}
}

type ValueType = {
  [InputType.OBJECT]: { [key: string]: any },
  [InputType.TEXT]: string
}
```
However, any of the changes above wouldn't be backwards compatible and could break not only internal references in the `aws-cdk` but also on any customer packages using the CDK.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
…ctly treated as objects (aws#14631)

This doesn't actually fix the issue aws#12935 as currently the Json paths won't be resolved for Lambda steps where the `Resource` is the Lambda ARN and not `arn:aws:states:::lambda:invoke`, but it at least fixes the issue for Text inputs when `payloadResponseOnly: true` and will avoid the same error from happening again if the `recurseObject` is called with a value that's not an object.

Ideally the `TaskInput.value` field should be changed to `{ [key: string]: any } | string` here to ensure the type check when sending the value to methods like `FieldUtils.renderObject`:
https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-stepfunctions/lib/input.ts#L65

Or even better the `TaskInput` should be made generic like:
```
export class TaskInput<T extends InputType> {
  ...
  private constructor(public readonly type: T, public readonly value: ValueType[T]) {}
}

type ValueType = {
  [InputType.OBJECT]: { [key: string]: any },
  [InputType.TEXT]: string
}
```
However, any of the changes above wouldn't be backwards compatible and could break not only internal references in the `aws-cdk` but also on any customer packages using the CDK.

----

*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 Related to AWS StepFunctions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants