Open bdovaz opened 1 year ago
It is an error thrown by ajv trying to load the schema.
This can be reproduced independently of v8r, just using ajv-cli:
$ curl "https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json" --output service-schema.json
...
$ npx ajv-cli@latest compile -s service-schema.json
schema service-schema.json is invalid
It is hitting the error on this line of the schema https://github.com/microsoft/azure-pipelines-vscode/blob/97f39ff988232860b35556dde725d448151ec5a0/service-schema.json#L1076 I'm not sure if its an issue with the schema itself or AJV.
Created an issue: https://github.com/ajv-validator/ajv/issues/2296
I was working on something else recently that made me realise what is going on here.
AJV constructs regular expressions with the unicode u
flag, as required by the spec: https://json-schema.org/understanding-json-schema/reference/string.html#regular-expressions JSON Schema regular expressions are unicode-aware.
In javascript, Unnecessary escape sequences are invalid with the u
flag.
So this
var regex = new RegExp("^[^\\/~\\^\\: \\[\\]\\\\]+(\\/[^\\/~\\^\\: \\[\\]\\\\]+)*$", "u")
throws a
Uncaught:
SyntaxError: Invalid regular expression: /^[^\/~\^\: \[\]\\]+(\/[^\/~\^\: \[\]\\]+)*$/: Invalid escape
I guess the reason this schema works with some validators is that maybe there are some JSON schema tools that either don't construct with the unicode flag, or this constraint (no unnecessary escape sequences when using unicode) is not there in other regexp engines. I've not really dug into it. Note that
var regex = new RegExp("^[^\\/~\\^\\: \\[\\]\\\\]+(\\/[^\\/~\\^\\: \\[\\]\\\\]+)*$")
constructs a regex without error.
I think the solution to this - if you wanted to submit a PR upstream to https://github.com/microsoft/azure-pipelines-vscode/ - would be to remove the unnecessary escapes on the :
characters.
var regex = new RegExp("^[^\\/~\\^: \\[\\]\\\\]+(\\/[^\\/~\\^: \\[\\]\\\\]+)*$", "u")
is valid with the unicode flag.
@chris48s I don't understand what is going on, I don't know if the error is in my file or in the schema itself (the url you mention).
My azure-pipelines.yml file should not be because it validates and runs correctly in Azure DevOps.