fix: resolve entity local references before inlining (#72) - #79
Merged
carolinerg1 merged 2 commits intoAug 20, 2026
Merged
Conversation
…rce-Protocol#72) Recursively resolve same-document $refs on the entity definition (such as #/$defs/version) upon extraction in preprocess_schemas.py before inlining into capability.json, service.json, and payment_handler.json. This prevents dangling references in preprocessed schemas, enables valid pattern constraints on generated models, and eliminates Version = TypeAliasType("Version", Any). Fixes Universal-Commerce-Protocol#72
damaz91
force-pushed
the
fix/resolve-entity-local-refs
branch
from
August 19, 2026 13:48
3c51f0a to
cbf46f8
Compare
Contributor
Author
vishkaty
approved these changes
Aug 19, 2026
vishkaty
left a comment
Contributor
There was a problem hiding this comment.
Verified at cbf46f8: regenerated from the pinned 2026-04-08 spec and re-ran the probes from #72, and all 21 entity-derived version fields across capability, service, and payment_handler now reject bad values with string_pattern_mismatch while valid 2026-04-08 baselines pass. Local suite is green (85 tests, up from 79 on main), regeneration byte-reproduces the committed models, and the only generated deltas beyond version are reordered but identical Config and Extends alias blocks.
carolinerg1
approved these changes
Aug 20, 2026
carolinerg1
merged commit Aug 20, 2026
d650f0b
into
Universal-Commerce-Protocol:main
16 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When preprocessing UCP schemas,
entity_def(ucp.json#/$defs/entity) is extracted and inlined into schemas that compose it (capability.json,service.json, andpayment_handler.json).Prior to this fix, same-document references within the entity definition (specifically
"version": { "$ref": "#/$defs/version" }) were copied verbatim into the target schemas. Because the destination schemas do not define$defs/version, these pointers failed to resolve against the destination document, leading to:$refpointers to#/$defs/version.referencing.exceptions.PointerToNowhere: '/$defs/version' does not exist.datamodel-codegenfalling back toVersion = TypeAliasType("Version", Any), leavingversionunvalidated acrosscapability.py,service.py, andpayment_handler.py.This change adds
resolve_local_refsto recursively resolve and inline local$refpointers in schema fragments against their origin document at extraction time. The entity definition is thus made self-contained before being inlined into consuming schemas, without introducing document-level reference cycles or modifying the external reference graph.Category (Required)
Please select one or more categories that apply to this change.
ucp-schematool (resolver, linter, validator). (Requires Maintainer approval)Related Issues
Fixes #72
Checklist
!for breaking changes).Screenshots / Logs (if applicable)
N/A