Skip to content
New issue

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

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

Already on GitHub? # to your account

StepFunctions: Label regex incorrect - denies s literal #29764

Closed
piurafunk opened this issue Apr 8, 2024 · 5 comments
Closed

StepFunctions: Label regex incorrect - denies s literal #29764

piurafunk opened this issue Apr 8, 2024 · 5 comments
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@piurafunk
Copy link
Contributor

piurafunk commented Apr 8, 2024

Describe the bug

When adding a label to a DistributedMap, the regex denies a string that contains an s. The regex is here

> new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi').test('RestoreTablesInBatch')
true

It also doesn't deny white space, which the \s is supposed to do at the front:

> new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi').test('Reto re Ta  b leInBatch')
false

My DistributedMap definition:

new stepFunctions.DistributedMap(this, 'RestoreTablesInBatch', {
    label: 'RestoreTablesInBatch',
    maxConcurrency: 40,
    itemReader: new stepFunctions.S3ObjectsItemReader({
        bucket: bucket,
        prefix: stepFunctions.JsonPath.stringAt('$.batch'),
    }),
    itemSelector: {
        's3Data': stepFunctions.JsonPath.stringAt('$$.Map.Item.Value'),
        'destination_cluster': stepFunctions.JsonPath.stringAt('$.destination_cluster'),
        'asymmetricPrivateKeyArn': stepFunctions.JsonPath.stringAt('$.asymmetricPrivateKeyArn'),
    },
})

Expected Behavior

The inverse of these 2 examples. With an s should be fine, with whitespace should be denied.

Current Behavior

s is denied, whitespace is allowed.

Reproduction Steps

> new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi').test('RestoreTablesInBatch')
true
> new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi').test('Reto re Ta  b leInBatch')
false

Possible Solution

My guess is that it's related to the quoting in a JS file. When node interprets it, the \ characters are being interpreted by Node and stripped out, rather than by the RegEx[ object. When I build the RegExp object, Node CLI prints without \ characters:

> new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi')
/[s?*<>{}\[\]:;,\|^~$#%&`"]|[-]|[-

It seems it's not being gathered correctly. The \s becomes just s, and even the last closing bracket is missing, from the 2nd unicode grouping.

I tried submitting a PR, but it was closed due to redtape: #29763
I submitted a 2nd one, this one didn't get automatically closed: #29765

Additional Information/Context

No response

CDK CLI Version

2.135.0

Framework Version

No response

Node.js Version

v20.12.1

OS

Docker - Alpine

Language

TypeScript

Language Version

No response

Other information

No response

@piurafunk piurafunk added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Apr 8, 2024
@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 8, 2024
@khushail khushail self-assigned this Apr 8, 2024
@khushail khushail added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@khushail
Copy link
Contributor

thanks for reporting this and submitting a PR @piurafunk . I see your PR has been reviewed and approved by CDK Team owner but its not updated with main branch code, thats why its not merged yet.

@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 29, 2024
@khushail khushail removed their assignment Apr 29, 2024
@piurafunk
Copy link
Contributor Author

Thanks, I hadn't noticed that. I've updated it just now.

@piurafunk
Copy link
Contributor Author

This is now resolved via the referenced PR.

Copy link

github-actions bot commented May 1, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants