Skip to content

Commit 19595b5

Browse files
committed
Gut the meat of the recursiveRef implementation for draft2019
It's buggy, and can lead to blowing up the stack with recursion errors. Done by (redundantly) checking schemas during test runs, even though the upstream test suite 'guarantees' they're valid. (Given that it uses this implementation to make that guarantee, bugs like the above went unnoticed.) Closes: #847
1 parent 5fea559 commit 19595b5

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

jsonschema/_legacy_validators.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,8 @@ def recursiveRef(validator, recursiveRef, instance, schema):
221221

222222
fragment = recursiveRef.lstrip("#")
223223
subschema = validator.resolver.resolve_fragment(target, fragment)
224-
yield from validator.descend(instance, subschema)
224+
# FIXME: This is gutted (and not calling .descend) because it can trigger
225+
# recursion errors, so there's a bug here. Re-enable the tests to
226+
# see it.
227+
subschema
228+
return []

jsonschema/tests/_suite.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def fn(this):
197197
return unittest.skipIf(reason is not None, reason)(fn)
198198

199199
def validate(self, Validator, **kwargs):
200+
Validator.check_schema(self.schema)
200201
resolver = jsonschema.RefResolver.from_schema(
201202
schema=self.schema,
202203
store=self._remotes,

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,18 @@ def leap_second(test):
360360
message="dynamicRef support isn't working yet.",
361361
subject="recursiveRef",
362362
)(test)
363+
or skip(
364+
message="These tests depends on dynamicRef working.",
365+
subject="id",
366+
case_description=(
367+
"Invalid use of fragments in location-independent $id"
368+
),
369+
)(test)
370+
or skip(
371+
message="These tests depends on dynamicRef working.",
372+
subject="defs",
373+
description="invalid definition schema",
374+
)(test)
363375
or skip(
364376
message="These tests depends on dynamicRef working.",
365377
subject="anchor",

jsonschema/tests/test_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ class MetaSchemaTestsMixin(object):
14101410
# TODO: These all belong upstream
14111411
def test_invalid_properties(self):
14121412
with self.assertRaises(exceptions.SchemaError):
1413-
self.Validator.check_schema({"properties": {"test": object()}})
1413+
self.Validator.check_schema({"properties": 12})
14141414

14151415
def test_minItems_invalid_string(self):
14161416
with self.assertRaises(exceptions.SchemaError):

0 commit comments

Comments
 (0)