Skip to content

aws-stepfunctions: Escaping curly braces not supported in intrinsic functions #29261

@clareliguori

Description

@clareliguori

Describe the bug

I am trying to escape curly braces in a state machine definition, for example:

const pass = new Pass(stack, 'pass', {
  parameters: {
    format: JsonPath.format('Hello {}, please format your response in JSON. For example: \\{ "name": "Bob" \\}', JsonPath.stringAt('$.Name')),
  },
});

Note that the first set of curly braces in the format string are for injecting the 'Name' field, and the second set are escaped using backslashes.

Expected Behavior

The resulting definition has the curly braces properly escaped.

Current Behavior

The escaping backslash before each curly brace is doubly-escaped, leading to an error when I try to execute the state machine:

Invalid template in States.Format: matching '}' not found for '{'.

The state definition when deployed to Step Functions shows double-escaping:

Hello {}, please format your response in JSON. For example: \\\\{ "name": "Bob" \\\\}

Reproduction Steps

See example above

Possible Solution

The logic here incorrectly assumes all backslashes should be escaped:
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/private/json-path.ts#L346-L347

Additional Information/Context

No response

CDK CLI Version

2.122.0

Framework Version

No response

Node.js Version

v18.19.1

OS

Linux

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-stepfunctionsRelated to AWS StepFunctionsbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions