-
-
Notifications
You must be signed in to change notification settings - Fork 582
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
jsonschema 4.10.0 has broken ASDF #981
Comments
Looking more deeply at the new warning issue I think the change that is breaking ASDF is the change from jsonschema/jsonschema/validators.py Lines 204 to 218 in ae0feea
In particular, I suspect the issue is that by using the jsonschema/jsonschema/validators.py Lines 1079 to 1112 in ae0feea
Draft202012Validator rather than a Draft4Validator (hence the warning). Currently, ASDF is only compatible with the Draft4 specification.
Are there any suggestions on how I can fix this issue? |
Hi. Please include some information about what reproduces the issue being reported. I'm not familiar with asdf, so ideally it should just be some Python code using this library, in which case I'd be happy to help diagnose. |
To reproduce the warning: from asdf.tests import helpers
import warnings
import asdf
snippit = """
example: !core/complex-1.0.0 1-1j
""".strip()
buff = helpers.yaml_to_asdf(snippit)
af = asdf.AsdfFile(ignore_unrecognized_tag=False, ignore_version_mismatch=False)
with warnings.catch_warnings():
warnings.simplefilter("error")
af._open_impl(af, buff, mode="rw") To reproduce the error: import asdf
af = asdf.AsdfFile({'a': 3 + 2j})
af.write_to('test.asdf') ASDF can be installed with
|
Thanks -- I was hoping you'd include code specifically for this library, which makes it easier than having to diagnose asdf itself, which as I mentioned I don't really have any familiarity with. You may also want to have a look at #982 -- are you perhaps subclassing validator classes for some reason? |
OK I got a minute to look, and indeed that seems to be the issue: https://github.com/asdf-format/asdf/blob/e0a6081e82bf69b9ce5f8dfa5b3dee5e85000e26/asdf/schema.py#L261 That's honestly not something that's really ever been supported, though of course without an error saying so it's unsurprising some folks did it :/ (here and #982). I believe there should be a minor fix that will probably make it work again for you, but I do intend to put the warning in finally and eventually make it error to subclass these -- as I say it's not something I've ever really wanted to support and isn't something I check carefully when making changes. Whatever is being done there should be possible without subclassing, though I'm certainly happy to help figure out how if need be, feel free to ping me. Perhaps I'll close this and we can centralize in #982 if that's OK with you, as I say, I hope I can make what you have work regardless. |
Copying comment from #982 (comment)
|
I think I'm seeing similar issues as well. Even if I rework things to not subclass the validator, it seems evolve() looses my custom resolver. That's about as far as I've gotten debugging it. |
I think the issue is related to validator_for() not finding the right validator if $schema URI doesn't quite match. Either a trailing '#' or http vs. https or both causes a mismatch. For dtschema, we're on draft2019-09 and now draft2020-12 validator gets selected at some point. I guess now that the validator is selected for each schema file instead of being fixed by the caller, a mismatched URI causes problems. |
Do you have anything I can run to reproduce? The default for |
Previously it was only used when $schema was not present, but clearly it should be used even when it is but the URI is not recognized. Combined with #981 this *hopefully* now handles the remaining downstream users with subclasses.
OK never mind I see the second issue -- which has to do with the subclasses also not using jsonschema.validators.validates to decorate the class (which registers the But, even without that, there was a second bug ("unrelated") which was I've fixed the latter, though yeah you should still stop inheriting from validators :) |
Your fix latest fix seems to fix most of asdf. Though it still breaks a feature (setting default values for objects in schemas) that has been depreciated for awhile. It was slated for removal in the next major asdf version anyways. The warnings that are now emitted by Thank you for your quick assistance. |
Cool. The first step should I think be to decouple your class from @attr.s
class ASDFValidator:
_validator = attr.ib(factory=lambda: jsonschema.Draft4Validator(whatever))
def iter_errors(self, *args, **kwargs):
do_stuff()
result = self._validator.iter_errors(*args, **kwargs)
do_more_stuff()
return asdfresult but I'd have to look closer to give more specific advice. I may have some time next week, so if you get stuck do ping me (here or on your repo). |
The release today of
jsonschema 4.10.0
seems to have broken ASDF in quite badly, see asdf-format/asdf#1172. Everything appears to function correctly withjsonschema 4.9.1
, and none of the changes between the versions stand out to me as a likely cause of the issue.There are at least two (possibly related errors) that I am seeing:
jsonschema/jsonschema/validators.py
Lines 1103 to 1111 in ae0feea
jsonschema
is no longer able to find the metaschema ASDF is using.originating here:
jsonschema/jsonschema/validators.py
Lines 92 to 98 in ae0feea
jsonschema
.I suspect there is a common cause of the issues ASDF is experiencing. I appreciate any help that can be offered.
The text was updated successfully, but these errors were encountered: