fix(preprocess): derive UcpMetadata union from $defs to include catalog - #58
Merged
damaz91 merged 3 commits intoJul 31, 2026
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
normalize_metadata_schemas hardcoded the UcpMetadata root union as five
members (platform, business, response_{checkout,order,cart}) and so
silently omitted response_catalog_schema, which is defined in ucp.json at
the 2026-04-08 release the SDK targets. The generated UcpMetadata
(src/ucp_sdk/models/schemas/ucp.py) therefore lacked ResponseCatalogSchema
(the class was generated from the $def, but the union omitted it), so a
UCP message carrying catalog-response metadata failed validation against
every model's `ucp` field.
Derive the union members from ucp.json's $defs instead: the discovery
profiles (platform/business) plus every response_*_schema. This fixes the
missing catalog entry and keeps the union complete as the protocol adds
response types, matching the data-driven approach used for minProperties
(Universal-Commerce-Protocol#55). Output order follows $defs insertion order, so existing members are
unchanged and catalog is appended.
Update the generated UcpMetadata in ucp.py accordingly. A full regeneration
is intentionally not bundled here: the tracked generated tree predates the
current ruff toolchain and regenerating adds unrelated formatting churn, so
only the one union line is edited — exactly what regeneration produces for
this fix.
Add MetadataUnionTest covering the derivation (profiles + all response
schemas, automatic pickup of new response types, exclusion of non-schema
defs such as request_schema, empty $defs) and update the existing
normalize_metadata_schemas test to assert the six-member union.
XiaolongZhang-TT
force-pushed
the
fix/ucp-metadata-union-catalog
branch
from
July 30, 2026 07:49
67897d7 to
6fe9262
Compare
XiaolongZhang-TT
marked this pull request as ready for review
July 30, 2026 07:54
damaz91
approved these changes
Jul 31, 2026
Contributor
|
Thanks! Also added the regenerated/linted classes! |
carolinerg1
approved these changes
Jul 31, 2026
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
normalize_metadata_schemashardcoded theUcpMetadataroot union as five members —platform_schema,business_schema,response_{checkout,order,cart}_schema— and so silently omittedresponse_catalog_schema, which is defined inucp.jsonat the2026-04-08release this SDK targets (0.4.x).response_catalog_schemais a live metadata type, referenced byshopping/catalog_lookup.jsonandshopping/catalog_search.json; the generatedUcpMetadata(src/ucp_sdk/models/schemas/ucp.py) therefore lackedResponseCatalogSchema(the class was generated from the$def, but the union omitted it), so a UCP message carrying catalog-response metadata would fail validation against the unifieducpfield type.This derives the union members from
ucp.json's$defsinstead: the discovery profiles (platform/business) plus everyresponse_*_schema. It fixes the missing catalog entry and keeps the union complete as the protocol adds response types — the same data-driven approach used forminPropertiesin #55. Output order follows$defsinsertion order, so the existing members are unchanged andcatalogis appended.The generated
UcpMetadatainucp.pyis updated by a single union line — exactly the changegenerate_models.shproduces for this fix. A full regeneration is intentionally not bundled: the tracked generated tree predates the current ruff toolchain and regenerating adds unrelated formatting churn (45 files reformatted). See Screenshots / Logs for verification.Category (Required)
Please select one or more categories that apply to this change.
ucp-schematool (resolver, linter, validator). (Requires Maintainer approval)Related Issues
None. (Spotted during an audit of the SDK code-generation pipeline against
release/2026-04-08.)Checklist
!for breaking changes).Screenshots / Logs (if applicable)
Before —
UcpMetadataunion (5 members, catalog missing):After —
UcpMetadataunion (6 members, catalog included):metadata_union_membersderived from the realrelease/2026-04-08ucp.json:Full suite green as CI runs it (
python -m unittest discover -s tests -p "test_*.py"): 27 passed, 0 failed. ruff (--ignore D,E501, matching the pre-commit hook),ruff format, and codespell are clean.