Skip to content
New issue

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

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

Already on GitHub? # to your account

(stepfunctions): itemSelector keys with null value are omitted #29549

Closed
anentropic opened this issue Mar 20, 2024 · 5 comments
Closed

(stepfunctions): itemSelector keys with null value are omitted #29549

anentropic opened this issue Mar 20, 2024 · 5 comments
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@anentropic
Copy link

Describe the bug

when configuring a Map state, the key with null value is omitted from the input data passed to the item processor

                    sfn.Map(
                        self,
                        "MyMap",
                        max_concurrency=self._max_concurrency,
                        items_path="$.partitioned.job_names",
                        item_selector={
                            "batch_size.$": "$.batch_size",
                            "job_name.$": "$$.Map.Item.Value",
                            "max_batches": None,
                        },
                        result_path="$.partition_results",
                    )

I am confused if this is intended or not

On the one hand sfn.Condition.is_null(...) exists, so it seems intended to be possible to deal with keys having null values?

On the other hand the "Data flow simulator" tool returns an error (No results for path: '[object Object]') if key has a null value:
Screenshot 2024-03-20 at 09 44 31

unclear if that means it's not supported or it's just a bug in the simulator

it is quite a common issue in JSON de/serializer code that the case of "key present but value is null" is conflated with "key not present" and null keys are omitted by default

however if it's not possible to pass keys with null values this complicates things in Step Functions particularly because many of the various methods with JSONPath args will error if the key is not present

leaving only the less satisfactory option of using some not-null value to mean null

Expected Behavior

all explicitly specified keys are propagated to the input

Current Behavior

keys with null value are omitted

Reproduction Steps

see above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.133.0 (build dcc1e75)

Framework Version

No response

Node.js Version

v18.18.0

OS

macOS 14.3.1

Language

Python

Language Version

3.11.5

Other information

No response

@anentropic anentropic added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Mar 20, 2024
@anentropic
Copy link
Author

I see now this bug has been turned into a mis-feature and I should use a workaround like sfn.JsonPath.string_to_json("null") where I want null values

@pahud
Copy link
Contributor

pahud commented Mar 20, 2024

Yes. Does this workraound work for you?

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@anentropic
Copy link
Author

yes it does

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 20, 2024
@pahud
Copy link
Contributor

pahud commented Jun 3, 2024

Closing this issue as the workaround is valid.

Feel free to reopen if there's still a concern.

@pahud pahud closed this as completed Jun 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

⚠️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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants