Skip to content

fix(core): correctly resolve list indices in JSON Pointer refs and improve docs #32041

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

anmol-aidora
Copy link

@anmol-aidora anmol-aidora commented Jul 15, 2025

  • Description:
    This PR fixes incorrect handling of numeric path tokens in internal JSON-Schema $ref resolution. Numeric tokens are now treated as zero-based list indices whenever the current node is a list, eliminating false-negative look-ups and spurious KeyErrors. The helper also raises an explicit “index out of range” error for invalid indices, validates that every reference starts with #, and returns a deep copy to prevent unintended mutation. A comprehensive doc-string and inline comments clarify pointer semantics, control flow, and error cases.

  • Issue: $ref paths with list indices (e.g. #/anyOf/0) raise KeyError in dereference_refs #32042

  • Dependencies:: None

…s and add thorough docs

* Handle numeric path tokens as zero-based list indices when the current
  node is a list, preventing false-negative look-ups and KeyErrors.
* Raise explicit “index out of range” errors for invalid indices.
* Keep existing dict-key resolution behaviour intact.
* Tighten validation: ensure every $ref starts with “#”.
* Return a deep copy of the resolved fragment to avoid accidental mutation.
* Added detailed doc-string and inline comments to clarify control flow,
  pointer semantics, and error cases.
@anmol-aidora anmol-aidora requested a review from eyurtsev as a code owner July 15, 2025 12:24
Copy link

vercel bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2025 1:43pm

Copy link

codspeed-hq bot commented Jul 15, 2025

CodSpeed WallTime Performance Report

Merging #32041 will not alter performance

Comparing anmol-aidora:patch-1 (d072dcc) with master (02d0a9a)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

Copy link

codspeed-hq bot commented Jul 15, 2025

CodSpeed Instrumentation Performance Report

Merging #32041 will not alter performance

Comparing anmol-aidora:patch-1 (d072dcc) with master (02d0a9a)

Summary

✅ 14 untouched benchmarks

Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a unit test that shows the case that breaks?

@eyurtsev eyurtsev self-assigned this Jul 15, 2025
@anmol-aidora
Copy link
Author

Would you mind adding a unit test that shows the case that breaks?

will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants