forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sfn): can't override toStateJson() from other languages (aws#24593)
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*
- Loading branch information
1 parent
22773d3
commit 9a5a91c
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as cdk from '@aws-cdk/core'; | ||
import { FakeTask } from './integ.state-machine-credentials'; | ||
import { renderGraph } from './private/render-util'; | ||
import { JsonPath } from '../lib'; | ||
|
||
test('JsonPath.DISCARD can be used to discard a state\'s output', () => { | ||
const stack = new cdk.Stack(); | ||
|
||
const task = new FakeTask(stack, 'my-state', { | ||
inputPath: JsonPath.DISCARD, | ||
outputPath: JsonPath.DISCARD, | ||
resultPath: JsonPath.DISCARD, | ||
}); | ||
|
||
expect(renderGraph(task)).toEqual({ | ||
StartAt: 'my-state', | ||
States: { | ||
'my-state': { | ||
End: true, | ||
Type: 'Task', | ||
Resource: expect.any(String), | ||
Parameters: expect.any(Object), | ||
// The important bits: | ||
InputPath: null, | ||
OutputPath: null, | ||
ResultPath: null, | ||
}, | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters