Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stepfunctions): regex in DistributedMap label is incorrectly escaping characters #29765

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,19 @@ describe('Distributed Map State', () => {

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();
});
});

function render(sm: stepfunctions.IChainable) {
Expand All @@ -777,4 +790,4 @@ function createAppWithMap(mapFactory: (stack: cdk.Stack) => stepfunctions.Distri
const map = mapFactory(stack);
new stepfunctions.StateGraph(map, 'Test Graph');
return app;
}
}