Skip to content
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

Issue386: FailFast should not cause exception on if #485

Merged
merged 2 commits into from
Nov 25, 2021

Conversation

gareth-robinson
Copy link
Contributor

@gareth-robinson gareth-robinson commented Nov 22, 2021

Fix for #386

When failFast is enabled the code that builds the ValidationMessages throws an exception rather than returning a Set.
In if/else/then blocks this could cause the validation to fail whenever an 'if' was false.
I've a basic change here to just wrap the if validation in a try/catch if that's appropriate?

Btw, when running the tests I found that Issue366Test wasn't working, as it was looking in the wrong location (but otherwise is not related to this change)

@@ -0,0 +1,5 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have all of the test cases in https://json-schema.org/understanding-json-schema/reference/conditionals.html#if-then-else

You could maybe make two arrays like so

{
  "passing": [
      { your example above },
      { other passing example from the link },
      ...
    ],
   "failing": [
       { "data": { a failing example from the link }, "expectedErrors":["error1", "error2"] },
       ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to have all the tests above in this 'fail fast' test.
I've also updated the draft2019-09/if-then-else.json and draft7/if-then-else.json to have the full set of tests from that link too.

@stevehu stevehu changed the title Issue386: FailFast should not cause exception on 'if' Issue386: FailFast should not cause exception on if Nov 24, 2021
Copy link
Contributor

@SiemelNaran SiemelNaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though @stevehu must approve

@stevehu stevehu merged commit fdae2f8 into networknt:master Nov 25, 2021
@stevehu
Copy link
Contributor

stevehu commented Dec 2, 2021

@gareth-robinson I don't know if I have merged the PR before you have updated the test cases. If that is the case, please resubmit the PR from your forked branch. The test cases are very important to ensure our code is not going to be broken by others. Thanks.

@gareth-robinson
Copy link
Contributor Author

Hi @stevehu, yeah I added the test cases in this commit: d7a8144, seems to have been included when you merged.

@stevehu
Copy link
Contributor

stevehu commented Dec 4, 2021

Excellent!. Thanks a lot for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants