Skip to content

Add test for "contains" with false "if" subschema #485

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

Merged
merged 1 commit into from
Jun 15, 2021
Merged

Add test for "contains" with false "if" subschema #485

merged 1 commit into from
Jun 15, 2021

Conversation

marksparkza
Copy link
Contributor

An intermediate solution to a problem I've been working on had contains failing when an if subschema failed.

My implementation only supports drafts 2019-09 and 2020-12, so I'm not 100% sure that this is a valid test for draft6 and draft7.

@karenetheridge
Copy link
Member

These two commits (with slightly different messages) can be merged together into one.

@marksparkza
Copy link
Contributor Author

Done!

Copy link
Member

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

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

How is this testing anything that isn't covered by https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/master/tests/draft2019-09/contains.json#L63-L78?

The if/else doesn't affect the behavior of contains in any way, so I'm not sure what value this test adds.

@karenetheridge
Copy link
Member

karenetheridge commented May 21, 2021

@marksparkza 's implementation had a different behaviour:

An intermediate solution to a problem I've been working on had contains failing when an if subschema failed.

..so it sounds like perhaps his handling of 'if' was incorrect? perhaps the tests should be moved to if.json, as the subschema containing an 'if' should not be false if the 'if' keyword itself is false (and there is no 'else'). It's not relevant to 'contains' (but please correct me if I'm wrong @marksparkza )

@marksparkza
Copy link
Contributor Author

@jdesrosiers

The if/else doesn't affect the behavior of contains in any way

The if/else shouldn't affect the behavior of contains in any way, but in my implementation it did. I was passing all tests, but had a hunch that I'd missed something. So I wrote this test, which my implementation failed.

By way of explanation:

In solving a larger problem (I was losing annotations and errors for array items, even though validation was being done correctly), I'd modified my contains implementation in such a way that it did not account for the behaviour of non-asserting keywords - not if specifically, though that's the only relevant case. I've since revised my implementation such that keyword non-assertion is dealt with transparently with respect to other keywords.

@karenetheridge

This was specifically a problem with the way my contains implementation processed its own subschema, so I think contains.json is the right place for the test. I think the more general problem of a subschema not being false if if is false is probably adequately covered by the first test ("ignore if without then or else") in if-then-else.json.

@jdesrosiers
Copy link
Member

If it's exposing a real bug, that's good enough for me. Carry on.

@Julian
Copy link
Member

Julian commented Jun 15, 2021

The above sounds reasonable to me (if it was a real bug an implementation had, we generally I think merge these kinds of things).

Merging, thanks!

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.

4 participants