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

docs(stepfunctions): use JsonPath.DISCARD in place of null for input #28661

Merged
merged 11 commits into from
Jan 16, 2024

Conversation

paulhcsun
Copy link
Contributor

@paulhcsun paulhcsun commented Jan 10, 2024

Update docs for use of sfn.JsonPath.DISCARD in place of null in TaskInput.fromObjects field value for languages that do not support null like Python.

Doc: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.TaskInput.html#:~:text=to%20a%20task.-,static%20fromObject(obj),-public%20static%20fromObject

Closes #16253.


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

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Jan 10, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 10, 2024 23:53
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 10, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@mrgrain
Copy link
Contributor

mrgrain commented Jan 11, 2024

Does JsonPath.DISCARD not work?

@paulhcsun paulhcsun added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jan 11, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 11, 2024 18:41

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@paulhcsun
Copy link
Contributor Author

@mrgrain JsonPath.DISCARD does work, I'm just not sure if the name of it is accurate for the purpose of replacing a null though, especially because the effect of using a null is not consistent across different cases. Taking one example provided in the issue:

"ItemResult": {
	"LastEvaluatedKey": JsonPath.DISCARD
     }

The name DISCARD here isn't the clearest of what we're trying to do but using NULL_VALUE is.

Actually reading the doc on it, it could make sense (Special string value to discard state input, output or result.). Perhaps I'm just thinking of DISCARD in a different context. Let me know what you think though.

@paulhcsun paulhcsun marked this pull request as ready for review January 11, 2024 19:07
Comment on lines 152 to 153
if (value === NULL_SUBSTITUTE) {
Object.assign(ret, handlers.handleNull(key, null));
Copy link
Contributor

@GavinZZ GavinZZ Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't read the original issue, but just curious that does the following not work? The reason that it's completely ignoring null value is because on line 162, we explicitly skipped null or undefined scenario. If we don't want to ignore it, can't we just assign a value instead?

if (value === null || value === undefined) {
     Object.assign(ret, handlers.handleNull(key, null));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think users want to specifically be able to distinguish null from undefined in typescript, but at the same time the two are the same in other languages like Python (None) so a magic value of some sort will satisfy both cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulhcsun's right. This isn't an issue in TS (at least not as far as I know), but in jsii (languages) which cannot distinguish between null and undefined. But ASL (as a JSON-ish schema) sometimes requires users to use null

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 11, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Jan 12, 2024

Actually reading the doc on it, it could make sense (Special string value to discard state input, output or result.). Perhaps I'm just thinking of DISCARD in a different context. Let me know what you think though.

I believe this has been named based on this feature and assuming that the only time someone actually wants null in the State Machine definition is for this reason. It's still the only reference to null that I can find in the Developer Guide, but that doesn't mean much.

https://docs.aws.amazon.com/step-functions/latest/dg/input-output-resultpath.html

If you look at the PRs and issue involved in JsonPath.DISCARD you might get some more context on it. Look out for comments and PRs by @RomainMuller

@mrgrain JsonPath.DISCARD does work, I'm just not sure if the name of it is accurate for the purpose of replacing a null though, especially because the effect of using a null is not consistent across different cases. Taking one example provided in the issue:

If we find that the naming/documentation for JsonPath.DISCARD isn't working for our users, we can definitely think about improving this. Aside from sprucing up the docs, I could imagine adding an alias for JsonPath.DISCARD, e.g. JsonPath.NULL.


FWIW, after confirming JsonPath.DISCARD works in Python, the issue should be closed. But we can still discuss DX improvements.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@paulhcsun paulhcsun changed the title fix(stepfunctions): renderObject ignores explicit null docs(stepfunctions): use JsonPath.DISCARD in place of null for input Jan 13, 2024
@paulhcsun paulhcsun added the pr-linter/exempt-test The PR linter will not require test changes label Jan 13, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 13, 2024 00:33

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

mergify bot commented Jan 16, 2024

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

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 16, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9a22bf3
  • 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 7bfb1d6 into aws:main Jan 16, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Jan 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(stepfunctions-tasks): LambdaInvoke - explicit null is not passed to lambda when using
5 participants