Skip to content

fix preprocess to expand properties dict instead of add as a node to … - #86

Open
ryanmco wants to merge 5 commits into
Universal-Commerce-Protocol:mainfrom
ryanmco:fix-preprocess-properties
Open

fix preprocess to expand properties dict instead of add as a node to …#86
ryanmco wants to merge 5 commits into
Universal-Commerce-Protocol:mainfrom
ryanmco:fix-preprocess-properties

Conversation

@ryanmco

@ryanmco ryanmco commented Aug 25, 2026

Copy link
Copy Markdown

Avoid traversing properties with names that match json schema keywords.

Error occurs when processing common/types/constraint_expression.json

Generating Pydantic models from preprocessed schemas...
Error at schema path 'common/types/constraint_expression.json#': ValidationError: 2 validation errors for JsonSchemaObject
properties.anyOf.JsonSchemaObject
  Input should be a valid dictionary or instance of JsonSchemaObject [type=model_type, input_value=['type', 'description', 'minItems', 'items'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.13/v/model_type
properties.anyOf.bool
  Input should be a valid boolean [type=bool_type, input_value=['type', 'description', 'minItems', 'items'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.13/v/bool_type

This is fixed by instead adding the properties mapping itself (the container dictionary { "prop_name": { ...schema... } }), it immediately adds each property's inner schema dictionary (v.values()) directly to the traversal list.

Before vs After

{
  "type": "object",
  "properties": {
    "user_id": { "type": "string", "$ref": "#/$defs/id" },
    "properties": { "type": "object", ... }
  }
}

Before

  1. Yields root object { "type": "object", "properties": { ... } }
  2. Yields the container dictionary { "user_id": { ... }, "properties": { ... } } (which is just a key-value map of property names, not a schema definition itself)
  3. Yields { "type": "string", "$ref": "#/$defs/id" }
  4. Yields { "type": "object", .... }

After (with the fix):
Yields root object { "type": "object", "properties": { ... } }
Yields { "type": "string", "$ref": "#/$defs/id" } (container is skipped)
Yields { "type": "object", ... }

This prevents functions inspecting yielded nodes (like checking for anyOf, properties,...) from the container map itself as if it were a schema.

Description

Category (Required)

Please select one or more categories that apply to this change.

  • 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)
  • [ x] 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

Checklist

  • [ x] I have followed the Contributing Guide (including Conventional Commits title requirements and ! for breaking changes).
  • I have updated the documentation (if applicable).
  • [ x] My changes pass all local linting and formatting checks.
  • [ x] 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)

…avoid traversing properties with names that match json schema keywords.
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Aug 25, 2026
@carolinerg1 carolinerg1 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants