You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Format validation will fail on "regex" fields which use syntaxes which are not valid in python, but are valid in other regex engines.
In the originating use-case for this issue, (?<foo>) was used as a name-capturing group. The trouble here is that (?< has a special meaning in python regular expressions which is not common to all regex engines. In general, (? ... ) expressions are a space of great variation between engines.
I'm not sure how best to handle this case. regex validation in jsonschema is done with python's regex engine with re.compile, but that is not strictly compatible with ECMA 262 regex syntax (which is the point of reference for JSON Schema).
JSON Schema itself notes that strict adherence to ECMA 262 is not necessarily feasible for all implementations, and recommends that schema authors use a safe subset of regex syntaxes.
A couple of years ago, jsonschema worked on supporting JS syntax, but it had to be backed out due to issues. The resulting js-regex package appears to be abandoned.
Roughly, I see a few options:
try to support this syntax with customized regex validation (HARD)
wrap the jsonschema regex format validator to look for (? followed by any character other than ! or =, and disable the check in those cases only
remove "regex" from the values of format which are supported/checked by check-jsonschema
add a flag to disable certain formats, e.g. --disable-formats "regex,date"
expect users encountering this issue to disable format checks altogether
Originating Comment
I've tested the new version and it broke our pre-commit schema validation:
Schema validation errors were encountered.
.github/renovate.json::regexManagers.0.matchStrings.0: '\\nminimum_pre_commit_version: (?<currentValue>.*?)\\n' is not a 'regex'
Format validation will fail on "regex" fields which use syntaxes which are not valid in python, but are valid in other regex engines.
In the originating use-case for this issue,
(?<foo>)
was used as a name-capturing group. The trouble here is that(?<
has a special meaning in python regular expressions which is not common to all regex engines. In general,(? ... )
expressions are a space of great variation between engines.I'm not sure how best to handle this case.
regex
validation injsonschema
is done with python's regex engine withre.compile
, but that is not strictly compatible with ECMA 262 regex syntax (which is the point of reference for JSON Schema).JSON Schema itself notes that strict adherence to ECMA 262 is not necessarily feasible for all implementations, and recommends that schema authors use a safe subset of regex syntaxes.
A couple of years ago,
jsonschema
worked on supporting JS syntax, but it had to be backed out due to issues. The resultingjs-regex
package appears to be abandoned.Roughly, I see a few options:
jsonschema
regex format validator to look for(?
followed by any character other than!
or=
, and disable the check in those cases onlyformat
which are supported/checked bycheck-jsonschema
--disable-formats "regex,date"
Originating Comment
Originally posted by @dudicoco in #19 (comment)
The text was updated successfully, but these errors were encountered: