Skip to content

Commit

Permalink
fix(sfn): stop replacing JsonPath.DISCARD with null
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RomainMuller committed Mar 21, 2023
1 parent 3b7431b commit 3918753
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts
Expand Up @@ -578,7 +578,6 @@ export function renderList<T>(xs: T[], mapFn: (x: T) => any, sortFn?: (a: T, b:
*/
export function renderJsonPath(jsonPath?: string): undefined | null | string {
if (jsonPath === undefined) { return undefined; }
if (jsonPath === JsonPath.DISCARD) { return null; }

if (!Token.isUnresolved(jsonPath) && !jsonPath.startsWith('$')) {
throw new Error(`Expected JSON path to start with '$', got: ${jsonPath}`);
Expand Down

0 comments on commit 3918753

Please sign in to comment.