Describe the bug
Condition.jsonata constructor validation fails for a multi-line JSONata strings. This is possible in other places.
const fails = `{%
true
%}`
const works = `{% true %}`
Regression Issue
Last Known Working CDK Library Version
No response
Expected Behavior
It should allow multiline JSONata strings, correctly detecting the opening and closing tags.
Current Behavior
Using a multiline template literal in Typescript as the condition:
const condition = `{%
true
%}`
Condition.jsonata(condition)
Throws the following on cdk synth:
JSONata expression must be start with '{%' and end with '%}', got '{%
true
%}'
From here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/condition.ts#L471
Reproduction Steps
The resultJsonata is fine as multiline, but the conditionJsonata won't synth unless it's put on one line, ie. const conditionJsonata = `{% true %}`;
import { Stack } from "aws-cdk-lib";
import {
Choice,
Condition,
DefinitionBody,
Pass,
StateMachine,
} from "aws-cdk-lib/aws-stepfunctions";
import { Construct } from "constructs";
export class ConditionStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
const conditionJsonata = `{%
true
%}`;
const resultJsonata = `{%
"passed"
%}`;
const choice = Choice.jsonata(this, `${id}-Choice`);
const condition = Condition.jsonata(conditionJsonata);
const pass = Pass.jsonata(this, `${id}-Pass`, {
outputs: {
result: resultJsonata,
},
});
const definition = choice.when(condition, pass);
new StateMachine(this, `${id}-StateMachine`, {
definitionBody: DefinitionBody.fromChainable(definition),
});
}
}
Possible Solution
The validation could be updated to add the s "dotAll" flag to the regex: if (!/^{%(.*)%}$/s.test(condition)) {
or a simpler non-regex if (!(condition.startsWith("{%") && condition.endsWith("%}"))) {.
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.190.0
AWS CDK CLI version
2.1019.2 (build c29855e)
Node.js Version
20.17.0
OS
Mac
Language
TypeScript
Language Version
No response
Other information
No response
Describe the bug
Condition.jsonataconstructor validation fails for a multi-line JSONata strings. This is possible in other places.Regression Issue
Last Known Working CDK Library Version
No response
Expected Behavior
It should allow multiline JSONata strings, correctly detecting the opening and closing tags.
Current Behavior
Using a multiline template literal in Typescript as the condition:
Throws the following on
cdk synth:From here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions/lib/condition.ts#L471
Reproduction Steps
The
resultJsonatais fine as multiline, but theconditionJsonatawon't synth unless it's put on one line, ie.const conditionJsonata = `{% true %}`;Possible Solution
The validation could be updated to add the
s"dotAll" flag to the regex:if (!/^{%(.*)%}$/s.test(condition)) {or a simpler non-regex
if (!(condition.startsWith("{%") && condition.endsWith("%}"))) {.Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.190.0
AWS CDK CLI version
2.1019.2 (build c29855e)
Node.js Version
20.17.0
OS
Mac
Language
TypeScript
Language Version
No response
Other information
No response