- 
 
- 
  Notifications
 You must be signed in to change notification settings 
- Fork 226
test a malformed pattern #386
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -49,11 +49,27 @@ | |
| "description": "pattern is not anchored", | ||
| "schema": {"pattern": "a+"}, | ||
| "tests": [ | ||
| { | ||
| "description": "doesn't match a substring", | ||
| "data": "xxyy", | ||
| "valid": false | ||
| }, | ||
| { | ||
| "description": "matches a substring", | ||
| "data": "xxaayy", | ||
| "valid": true | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "description": "pattern is malformed", | ||
| "schema": {"pattern": "hel{1,"}, | ||
| "tests": [ | ||
| { | ||
| "description": "invalid regex does not match", | ||
| "data": "hello", | ||
| "valid": false | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For drafts pre-2019-09 this is (potentially) incorrect I think -- it depends whether the metaschema it's run under is validating formats or treating them as annotations or whatever. So for those this'd need to go in optional. For 2019-09 I don't remember what changed -- do you enable format via a vocabulary and then it has to be respected, or what? (Also this is invalid JSON but probably you'll notice that part) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not assuming/expecting the metaschema to use a format validation. Even if no validation is done on the schema at all, it should still return a non-valid result at runtime. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. invalid json fixed -- and the test suite is now happy, so it looks like the json was just parsing badly before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That may not be the case. An implementation is free to blow up entirely in this case if you give it an invalid schema and it isn't validating it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (i.e. it's valid for the result here to be "my validator blows up" rather than returning invalid) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As well, assuming that "valid=false" for failed schemas changes the meaning of "valid" for the tests in that suite. It’s also bad practice to have meanings of fields change depending on other variables. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps there should be another flag to indicate invalid schemas (apart from  That would be different from  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we've been discussing this across a few different PRs and in slack. There hasn't been any consensus yet as to how to declare this in tests (with an extra flag? a new directory under optional/? both of these?) or how to document how implementations should deal with it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to merge the outstanding PRs on tests in the "normal" category before addressing this. I.e. #354 and the PRs being split off of it. Let's get those merged, then we can hit cases that may require a structural change. Could definitely use more eyes reviewing those PRs so we can get them off the queue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, my implementation gives an (arguably incorrect) error, but doesn't blow up: 
 (Interestingly, .Net doesn't think this is an invalid pattern.) I think this is one of the things I had to account for in some other regex test where .Net didn't support something. I switch from deserializing the regex directly to just deserializing a string and lazily parsing the regex. | ||
| } | ||
| ] | ||
| } | ||
| ] | ||