Skip to content

Preserve empty JSON Pointer keys and unique validator names - #224

Open
jadenfix wants to merge 1 commit into
horejsek:masterfrom
jadenfix:fix-empty-json-pointer-keys
Open

jadenfix wants to merge 1 commit into
horejsek:masterfrom
jadenfix:fix-empty-json-pointer-keys

Conversation

@jadenfix

Copy link
Copy Markdown

Valid JSON Pointers through an empty root key currently resolve incorrectly. For example, a schema whose value property references #/ should use the schema under the root's "" key; instead a valid integer value can be rejected as an object. #//child also drops the initial empty key.

Two changes are needed for that consumer path:

  • Preserve empty leading reference tokens, while retaining an empty fragment as the whole document.
  • Assign stable unique names to referenced validators. The root and #/ otherwise sanitize to the same function name and overwrite one another. Ordinary non-colliding names remain unchanged.

The 16 focused tests cover local and handler-loaded references through both compile() and compile_to_code(), empty keys, ordinary/root/array references, tilde and percent escapes, name collisions, and URI alias reuse. On the baseline, 15 fail and the ordinary-reference control passes.

Validation:

  • Python 3.14 and the supported floor Python 3.10: full CI command pytest -m "not benchmark": 4,525 passed, 12 deselected, 449 xfailed, 936 non-strict xpassed. Unchanged baseline: 4,509 passed with the identical deselection/xfail/XPASS counts.
  • Installed wheel on Python 3.10: real schema/data files through compiled validators and generated Python modules pass 18 checks, including valid values and both child/root type rejection. The baseline rejects the same valid file input.
  • Four ordinary schemas produce byte-identical generated code before and after the change.
  • Changed resolver module: Pylint 10/10; git diff --check passes. Whole-project Pylint retains six identical baseline diagnostics in unrelated modules; it is separate from the required CI pytest command.

This is a focused reference-resolution fix, not a claim of complete JSON Pointer conformance. No external schema network requests were made; handler coverage uses in-memory schema data. Hosted CI and other platforms remain pending.

AI assistance: Codex prepared the patch, tests, and description. A separate Codex agent reviewed the final resolver and generator call sites, independently ran all 16 focused tests, and executed the installed-wheel consumer. This is agent review, not human review.

This branch has not been deployed

No deployments
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.

1 participant