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

step functions: Map.jsonata does not support assign #33403

Closed
1 task
joerino96 opened this issue Feb 11, 2025 · 2 comments · Fixed by #33423 or #33404
Closed
1 task

step functions: Map.jsonata does not support assign #33403

joerino96 opened this issue Feb 11, 2025 · 2 comments · Fixed by #33423 or #33404
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@joerino96
Copy link

Describe the bug

Map.jsonata does not support the assign field provided by CDK, causing a compile error.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Map.jsonata is able to set the assign field.

Current Behavior

A compile error is thrown: Object literal may only specify known properties, and 'assign' does not exist in type 'MapJsonataProps'.

Reproduction Steps

The following code causes a compile error:

    const myMap = Map.jsonata(scope, "MyMap", {
        items: ProvideItems.jsonata("{% $runInput %}"),
        itemSelector: {
            runs: "{% $states.context.Map.Item.Value %}",
        },
        assign: {},
    })

However, the workaround for using the classic Map constructor and setting the query language to jsonata compiles correctly.

    const myMap = new Map(scope, "MyMap", {
        queryLanguage: QueryLanguage.JSONATA,
        items: ProvideItems.jsonata("{% $runInput %}"),
        itemSelector: {
            runs: "{% $states.context.Map.Item.Value %}",
        },
        assign: {},
    })

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.178.1

Framework Version

No response

Node.js Version

Node 18

OS

macOS 15.3

Language

TypeScript

Language Version

No response

Other information

No response

@joerino96 joerino96 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 11, 2025
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Feb 11, 2025
@pahud
Copy link
Contributor

pahud commented Feb 12, 2025

Hi @joerino96,

Thank you for reporting this issue. After investigation, this appears to be a valid bug where the MapJsonataProps interface is missing the assign property that should be supported, similar to the classic Map constructor.

Issue Analysis:

  • The assign property is correctly supported when using new Map() with QueryLanguage.JSONATA
  • However, the same property is not included in the type definitions for Map.jsonata()
  • This is likely an oversight in the type definitions since both APIs should support the same functionality

Current Workaround:
As you've discovered, you can use the classic constructor approach:

new Map(scope, "MyMap", {
    queryLanguage: QueryLanguage.JSONATA,
    items: ProvideItems.jsonata("{% $runInput %}"),
    itemSelector: {
        runs: "{% $states.context.Map.Item.Value %}",
    },
    assign: {},
})

We'll work on fixing this by updating the MapJsonataProps interface to include the assign property. Making it a p1.

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 12, 2025
@GavinZZ GavinZZ self-assigned this Feb 12, 2025
GavinZZ added a commit that referenced this issue Feb 13, 2025
…#33423)

### Issue # (if applicable)

Closes #33403 and #33374 and #33396.

### Reason for this change

There are three issues here:
1. For summary, the first issue is basically that assign property cannot
be accessed with using Map.jsonata(...) but available if we directly
create map through new Map(...) using JSONATA query language.
2. For summary, the second issue is that JSONATA main PR added the
outputs and assign property in the CatchProps interface for AddCatch
functionality. But I don't think it's being used in the actual
`addCatch` call
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/states/state.ts#L398.
3. Result writer and item reader class do not support using JSONATA.
Deployment will fails due to if SFN is set to use JSONATA, it expects
`Arguments` in the ASL instead of `Parameters`.

### Description of changes

Fix both issues by fixing the interface inheritance and added the props
to `AddCatch` method.
Support `JSONATA` as the query language.

### Description of how you validated changes

Added integ test and unit test to make sure that 

### Checklist
- [ ] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
GavinZZ added a commit that referenced this issue Feb 19, 2025
### Issue # (if applicable)

Closes #33403 and #33374 and #33396.

### Reason for this change

There are three issues here:
1. For summary, the first issue is basically that assign property cannot
be accessed with using Map.jsonata(...) but available if we directly
create map through new Map(...) using JSONATA query language.
2. For summary, the second issue is that JSONATA main PR added the
outputs and assign property in the CatchProps interface for AddCatch
functionality. But I don't think it's being used in the actual
`addCatch` call
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/states/state.ts#L398.
3. Result writer and item reader class do not support using JSONATA.
Deployment will fails due to if SFN is set to use JSONATA, it expects
`Arguments` in the ASL instead of `Parameters`.

### Description of changes

Fix both issues by fixing the interface inheritance and added the props
to `AddCatch` method.
Support `JSONATA` as the query language.

### Description of how you validated changes

Added integ test and unit test to make sure that 

### Checklist
- [ ] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2025
yashkh-amzn pushed a commit to yashkh-amzn/aws-cdk that referenced this issue Feb 21, 2025
### Issue # (if applicable)

Closes aws#33403 and aws#33374 and aws#33396.

### Reason for this change

There are three issues here:
1. For summary, the first issue is basically that assign property cannot
be accessed with using Map.jsonata(...) but available if we directly
create map through new Map(...) using JSONATA query language.
2. For summary, the second issue is that JSONATA main PR added the
outputs and assign property in the CatchProps interface for AddCatch
functionality. But I don't think it's being used in the actual
`addCatch` call
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/states/state.ts#L398.
3. Result writer and item reader class do not support using JSONATA.
Deployment will fails due to if SFN is set to use JSONATA, it expects
`Arguments` in the ASL instead of `Parameters`.

### Description of changes

Fix both issues by fixing the interface inheritance and added the props
to `AddCatch` method.
Support `JSONATA` as the query language.

### Description of how you validated changes

Added integ test and unit test to make sure that 

### Checklist
- [ ] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
3 participants