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(sfn): can't override toStateJson() from other languages #24593

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

RomainMuller
Copy link
Contributor

If any part of a state's JSON representation is null, that value will be replaced by undefined when jsii sends data to the other language, resulting in a change of semantics.

Multi-language APIs cannot differentiate between null and undefined as non-JS languages typically fail to distinguish between them... In order to address that, a JsonNull value was added which serializes to null (via Javascript's standard toJSON method), which must be used in such cases where null may need to cross the language boundary.

The JsonPath.DISCARD value is now a string-token representation of the JsonNull instance.

Fixes #14639
Fixes aws/jsii#3999


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

@aws-cdk-automation aws-cdk-automation requested a review from a team March 13, 2023 13:30
@github-actions github-actions bot added bug This issue is a bug. p2 labels Mar 13, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 13, 2023
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.

If any part of a state's JSON representation is `null`, that value will
be replaced by `undefined` when jsii sends data to the other language,
resulting in a change of semantics.

Multi-language APIs cannot differentiate between `null` and `undefined`
as non-JS languages typically fail to distinguish between them... In
order to address that, a `JsonNull` value was added which serializes to
`null` (via Javascript's standard `toJSON` method), which must be used
in such cases where `null` may need to cross the language boundary.

The `JsonPath.DISCARD` value is now a string-token representation of the
`JsonNull` instance.

Fixes #14639
@RomainMuller RomainMuller marked this pull request as ready for review March 13, 2023 13:48
@RomainMuller RomainMuller added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Mar 13, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 13, 2023 13:52

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 10f168e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Mar 13, 2023

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).

@mergify mergify bot merged commit e955d18 into main Mar 13, 2023
@mergify mergify bot deleted the rmuller/json-null branch March 13, 2023 14:26
@@ -579,7 +580,7 @@ export function renderJsonPath(jsonPath?: string): undefined | null | string {
if (jsonPath === undefined) { return undefined; }
if (jsonPath === JsonPath.DISCARD) { return null; }

Choose a reason for hiding this comment

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

I think this line might still need to be updated for this to work properly. Even though JsonPath.DISCARD has been updated to a JsonNull token, this line will still evaluate truthy and return null, which in other languages like Python would translate to undefined. Perhaps this should return a JsonNull token as well?

RomainMuller added a commit that referenced this pull request Mar 21, 2023
Follow-up to #24593. The `renderJsonPath` function is subsituting a
literal `null` for `JsonPath.DISCARD`, which results in the key being
dropped if the value is sent across a language boundary, which
effectively changes semantics.

The `JsonPath.DISCARD` value is a `Token` that ultimately resolves to
`null`, and it must be preserved as such so that it is safe to exchange
across languages.

Thanks to @beck3905 for reporting & diagnosing this.
mergify bot pushed a commit that referenced this pull request Mar 21, 2023
Follow-up to #24593. The `renderJsonPath` function is subsituting a literal `null` for `JsonPath.DISCARD`, which results in the key being dropped if the value is sent across a language boundary, which effectively changes semantics.

The `JsonPath.DISCARD` value is a `Token` that ultimately resolves to `null`, and it must be preserved as such so that it is safe to exchange across languages.

Thanks to @beck3905 for reporting & diagnosing this.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 28, 2023
If any part of a state's JSON representation is `null`, that value will be replaced by `undefined` when jsii sends data to the other language, resulting in a change of semantics.

Multi-language APIs cannot differentiate between `null` and `undefined` as non-JS languages typically fail to distinguish between them... In order to address that, a `JsonNull` value was added which serializes to `null` (via Javascript's standard `toJSON` method), which must be used in such cases where `null` may need to cross the language boundary.

The `JsonPath.DISCARD` value is now a string-token representation of the `JsonNull` instance.

Fixes aws#14639
Fixes aws/jsii#3999

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 28, 2023
Follow-up to aws#24593. The `renderJsonPath` function is subsituting a literal `null` for `JsonPath.DISCARD`, which results in the key being dropped if the value is sent across a language boundary, which effectively changes semantics.

The `JsonPath.DISCARD` value is a `Token` that ultimately resolves to `null`, and it must be preserved as such so that it is safe to exchange across languages.

Thanks to @beck3905 for reporting & diagnosing this.

----

*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
bug This issue is a bug. contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
4 participants