Skip to content

fix: allow equivalent metadata union members - #76

Open
FanouZeng-TT wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
FanouZeng-TT:fix/metadata-root-anyof
Open

fix: allow equivalent metadata union members#76
FanouZeng-TT wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
FanouZeng-TT:fix/metadata-root-anyof

Conversation

@FanouZeng-TT

Copy link
Copy Markdown
Contributor

Description

normalize_metadata_schemas() synthesizes a root union for ucp.json using oneOf:

ucp["oneOf"] = [
    {"$ref": f"#/$defs/{name}"} for name in metadata_union_members(ucp)
]

response_cart_schema, response_catalog_schema, and response_order_schema have the same validation shape; their differences are limited to annotations such as title and description. Any metadata instance matching one of these response profiles therefore matches all three, so the generated oneOf rejects it for matching more than one branch.

Fix: synthesize the metadata type union with anyOf. This preserves the existing member list while allowing equivalent response profiles, matching the generated Pydantic Union behavior.

Category (Required)

  • Core Protocol: Changes to the base communication layer, global context, or breaking refactors. (Requires Technical Council approval)
  • Governance/Contributing: Updates to GOVERNANCE.md, CONTRIBUTING.md, or CODEOWNERS. (Requires Governance Council approval)
  • Capability: New schemas (Discovery, Cart, etc.) or extensions. (Requires Maintainer approval)
  • Documentation: Updates to README, or documentations regarding schema or capabilities. (Requires Maintainer approval)
  • Infrastructure: CI/CD, Linters, or build scripts. (Requires DevOps Maintainer approval)
  • Maintenance: Version bumps, lockfile updates, or minor bug fixes. (Requires DevOps Maintainer approval)
  • SDK: Language-specific SDK updates and releases. (Requires DevOps Maintainer approval)
  • Samples / Conformance: Maintaining samples and the conformance suite. (Requires Maintainer approval)
  • UCP Schema: Changes to the ucp-schema tool (resolver, linter, validator). (Requires Maintainer approval)
  • Community Health (.github): Updates to templates, workflows, or org-level configs. (Requires DevOps Maintainer approval)

Related Issues

Fixes #73

Checklist

  • I have followed the Contributing Guide (including Conventional Commits title requirements and ! for breaking changes).
  • I have updated the documentation (if applicable).
  • My changes pass all local linting and formatting checks.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • (For Core/Capability) I have included/updated the relevant JSON schemas.
  • I have regenerated Python Pydantic models by running generate_models.sh under python_sdk.

Screenshots / Logs (if applicable)

  • Draft 2020-12 reproduction: the synthesized oneOf returns one validation error for equivalent response members; anyOf returns zero.
  • uv run python -m unittest discover -s tests -p 'test_*.py' — 77 passed.
  • ./generate_models.sh 2026-04-08 — completed; no model behavior diff.
  • uvx pre-commit run --all-files — passed.
  • git diff --check — passed.

@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Synthesized ucp metadata oneOf can never be satisfied

2 participants