Skip to content

matchDiffLines causes FiltersValidator: ValidationError #681

@CloutKhan

Description

@CloutKhan

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 }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working👀.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions