Skip to content

matchDiffLines causes FiltersValidator: ValidationError #681

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

Open
CloutKhan opened this issue Apr 4, 2025 · 1 comment
Open

matchDiffLines causes FiltersValidator: ValidationError #681

CloutKhan opened this issue Apr 4, 2025 · 1 comment
Labels
bug Something isn't working 👀.

Comments

@CloutKhan
Copy link

CloutKhan commented Apr 4, 2025

Describe the bug
I am using a regex that is valid regular js regex, that is causing matchDiffLines to complain.

To Reproduce

use a matchDiffLines regex with a {<min>,<max>} on the last character, and it causes ValidationError "Invalid argument <max>$/"

Expected behavior

Somewhere, anywhere, the regex spec / templating spec that gitstream actually accepts, should be stated. I've tested the regex with the only mention I can find, nunjucks, but gitstream still throws this error.

More

This test in nunjucks shows regexing an arn with a quantifier works

const nunjucks = require('nunjucks')
nunjucks.renderString('{% set regExp = r/^\\+arn:aws:service:(region-abc|region-xyz):\\d{12}:service-prefix\\/\\w[\\w\-]{1,255}$/ %}{% if regExp.test("+arn:aws:service:region-abc:012345678901:service-prefix/abc") %}match{% endif %}')

But using both either this string, or with all the double escapes replaced with single escapes (which nunjucks fails on) produce the same error in gitstream;

regex_arns_addition: {{ source.diff.files | matchDiffLines(regex=r/^\\+arn:aws:service:(region-abc|region-xyz):\\d{12}:service-prefix\\/\\w[\\w\-]{1,255}$/, ignoreWhiteSpaces=true) | every }}
# or
regex_arns_addition: {{ source.diff.files | matchDiffLines(regex=r/^\+arn:aws:service:(region-abc|region-xyz):\d{12}:service-prefix\/\w[\w\-]{1,255}$/, ignoreWhiteSpaces=true) | every }}

produces either

error: ValidationError: Line [40]: Invalid argument 255$/ for filter matchDiffLines in expression {{ source.diff.files | matchDiffLines(regex=r/^\\+arn:aws:service:(region-abc|region-xyz):\\d{12}:service-prefix\\/\\w[\\w\-]{1,255}$/, ignoreWhiteSpaces=true) | every }}
# or
error: ValidationError: Line [40]: Invalid argument 255$/ for filter matchDiffLines in expression {{ source.diff.files | matchDiffLines(regex=r/^\+arn:aws:service:(region-abc|region-xyz):\d{12}:service-prefix\/\w[\w\-]{1,255}$/, ignoreWhiteSpaces=true) | every }}
@CloutKhan CloutKhan added the bug Something isn't working label Apr 4, 2025
@PavelLinearB
Copy link
Contributor

Hi @CloutKhan
Can you please share an example cm file and a link to a PR where you experienced this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 👀.
Projects
None yet
Development

No branches or pull requests

2 participants