You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw strange issues while adding schemas to a project I was working on. Despite knowing I was passing a valid instance in, I was getting errors like {} is not valid under any of the given schemas. I eventually traced this down to one of the in-tree validators (here, fwiw), which has the unfortunate side-effect of mutating the input instance. When the schema is using oneOf, the check against the first sub-schema ended up deleting all keys from the instance, causing the checks against subsequent sub-schemas to fail.
This is 100% not an issue with jsonschema but it is something I think it might be able to help mitigate. I could see us either (a) always doing a deepcopy of the instance before passing it to the validator, or (b) doing a deepcopy and comparing against instance after the call, with an exception raised if they're not identical. There might also be other approaches possible. In any case, I'm happy to help resolve this, assuming we agree it's a thing we'd like to address.
The text was updated successfully, but these errors were encountered:
stephenfin
added a commit
to stephenfin/jsonschema
that referenced
this issue
Mar 5, 2025
I saw strange issues while adding schemas to a project I was working on. Despite knowing I was passing a valid instance in, I was getting errors like
{} is not valid under any of the given schemas
. I eventually traced this down to one of the in-tree validators (here, fwiw), which has the unfortunate side-effect of mutating the inputinstance
. When the schema is usingoneOf
, the check against the first sub-schema ended up deleting all keys from theinstance
, causing the checks against subsequent sub-schemas to fail.This is 100% not an issue with
jsonschema
but it is something I think it might be able to help mitigate. I could see us either (a) always doing adeepcopy
of the instance before passing it to the validator, or (b) doing a deepcopy and comparing againstinstance
after the call, with an exception raised if they're not identical. There might also be other approaches possible. In any case, I'm happy to help resolve this, assuming we agree it's a thing we'd like to address.The text was updated successfully, but these errors were encountered: