python-jsonschema / python-jsonschema/jsonschema

Getting $ref history

Open
#1,146 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dialects v2 Enhancement Error Reporting
Dominant language
Python
Stars
5k
Forks
671
Avg merge
1d 1h
Merged PRs (30d)
10

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the validator.iter_errors example in the issue and review reference #1144, then trace how the deprecated validator.resolver exposes the $ref scope history. Done means the project has a supported way to retrieve this debugging information without relying on the deprecated resolver, with the expected behavior documented or covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.