gitstream icon indicating copy to clipboard operation
gitstream copied to clipboard

matchDiffLines causes `FiltersValidator: ValidationError`

Open CloutKhan opened this issue 8 months ago • 1 comments

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 avatar Apr 04 '25 04:04 CloutKhan

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

PavelLinearB avatar Apr 06 '25 14:04 PavelLinearB