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

Getting $ref history #1146

Open
atsuoishimoto opened this issue Jul 28, 2023 · 1 comment
Open

Getting $ref history #1146

atsuoishimoto opened this issue Jul 28, 2023 · 1 comment
Labels
Dialects v2 Issues which will likely be addressed as part of reworked dialect support Enhancement Some new desired functionality Error Reporting Issues related to clearer or more robust validation error reporting

Comments

@atsuoishimoto
Copy link

In large schemas, understanding which $ref is being referenced when an error occurs can be helpful in debugging. We used to refer to the history of $ref with (ill-mannered) code like this:

for error in validator.iter_errors(instance):
    print(validator.resolver._scopes_stack)
    print(error)

However, with the current version of jsonschema, validator.resolver is deprecated, and it will be not possible to refer to it.

Is there a legitimate way to retrieve this information in jsonschema?

Reference: #1144

@Julian Julian added the Enhancement Some new desired functionality label Jul 28, 2023
@Julian
Copy link
Member

Julian commented Jul 28, 2023

(Bringing over a comment here for us to think about):

Doing this is likely required to support #1008 regardless, because in the standard output formats, $refs actually are preserved in error paths in a few places.

But to do this correctly we'd also need to handle preserving $dynamicRef and $recursiveRef references, so some extra thought is needed.

On the bright side the objects used within the referencing library were written partially to support this (referencing's Resolver.dynamic_scope essentially contains this information).

Thanks for filing the issue (and ideas welcome from anyone thinking about this).

@Julian Julian added the Error Reporting Issues related to clearer or more robust validation error reporting label Jul 28, 2023
@Julian Julian added the Dialects v2 Issues which will likely be addressed as part of reworked dialect support label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dialects v2 Issues which will likely be addressed as part of reworked dialect support Enhancement Some new desired functionality Error Reporting Issues related to clearer or more robust validation error reporting
Projects
None yet
Development

No branches or pull requests

2 participants