From 29a9a14c402288b1fe7b18b0779d0ef3f4221a2e Mon Sep 17 00:00:00 2001 From: James Funk Date: Mon, 8 Apr 2024 10:47:32 -0600 Subject: [PATCH 1/5] Update distributed-map.ts Regex is incorrect. Switching to basic regex. Fixing regex to properly escape special characters --- .../aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts index 89453f316aebe..c644809c11ab7 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts @@ -172,7 +172,7 @@ export class DistributedMap extends MapBase implements INextable { errors.push('label must be 40 characters or less'); } - let labelRegex = new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi'); + let labelRegex = /[\s\?\*\<\>\{\}\\[\]\:\;\,\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]/gi if (labelRegex.test(this.label)) { errors.push('label cannot contain any whitespace or special characters'); } From 8bf7173869807652f0cf2f36c258dfb4280993ab Mon Sep 17 00:00:00 2001 From: James Funk Date: Mon, 8 Apr 2024 11:13:11 -0600 Subject: [PATCH 2/5] Add missing `;` --- .../aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts index c644809c11ab7..00c24e02165e8 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts @@ -172,7 +172,7 @@ export class DistributedMap extends MapBase implements INextable { errors.push('label must be 40 characters or less'); } - let labelRegex = /[\s\?\*\<\>\{\}\\[\]\:\;\,\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]/gi + let labelRegex = /[\s\?\*\<\>\{\}\\[\]\:\;\,\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]/gi; if (labelRegex.test(this.label)) { errors.push('label cannot contain any whitespace or special characters'); } From d3d57ffd6f921843291c07c8516d51705386c987 Mon Sep 17 00:00:00 2001 From: James Funk Date: Mon, 8 Apr 2024 11:18:49 -0600 Subject: [PATCH 3/5] Add label regex test in distributed-map.test.ts --- .../aws-stepfunctions/test/distributed-map.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts index e9ee37d453d59..099d346f12aed 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts @@ -763,7 +763,17 @@ describe('Distributed Map State', () => { return map; }); - expect(() => app.synth()).toThrow(/label cannot contain any whitespace or special characters/); + test('does not fail in synthesis if label has 's', () => { + const app = createAppWithMap((stack) => { + const map = new stepfunctions.DistributedMap(stack, 'Map State', { + label: 's', + itemsPath: stepfunctions.JsonPath.stringAt('$.inputForMap'), + }); + + return map; + }); + + app.synth(); }); }); @@ -777,4 +787,4 @@ function createAppWithMap(mapFactory: (stack: cdk.Stack) => stepfunctions.Distri const map = mapFactory(stack); new stepfunctions.StateGraph(map, 'Test Graph'); return app; -} \ No newline at end of file +} From 452ddedfd5927d0604fa70703e56c8dd5244f133 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:28:38 -0700 Subject: [PATCH 4/5] Update distributed-map.test.ts --- .../aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts index 099d346f12aed..bfe4985914f3c 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts @@ -763,7 +763,7 @@ describe('Distributed Map State', () => { return map; }); - test('does not fail in synthesis if label has 's', () => { + test('does not fail in synthesis if label has `s`', () => { const app = createAppWithMap((stack) => { const map = new stepfunctions.DistributedMap(stack, 'Map State', { label: 's', From 90b28c7ed6b6caf23b7c38a036485b3c4158c44b Mon Sep 17 00:00:00 2001 From: James Funk Date: Mon, 29 Apr 2024 16:31:11 -0600 Subject: [PATCH 5/5] Fix mangling of a different test --- .../aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts index bfe4985914f3c..56795af26cbd3 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts @@ -763,6 +763,9 @@ describe('Distributed Map State', () => { return map; }); + expect(() => app.synth()).toThrow(/label cannot contain any whitespace or special characters/); + }); + test('does not fail in synthesis if label has `s`', () => { const app = createAppWithMap((stack) => { const map = new stepfunctions.DistributedMap(stack, 'Map State', {