Skip to content

fix: enforce additionalProperties:false in generated models - #70

Merged
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
FanouZeng-TT:fix/enforce-additional-properties-false
Aug 12, 2026
Merged

fix: enforce additionalProperties:false in generated models#70
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
FanouZeng-TT:fix/enforce-additional-properties-false

Conversation

@FanouZeng-TT

Copy link
Copy Markdown
Contributor

Description

Three object schemas in the pinned spec declare additionalProperties: false with named properties:

  • types/error_response.json (root ErrorResponse)
  • types/merchant_fulfillment_config.json (allows_multi_destination)
  • types/business_fulfillment_config.json (allows_multi_destination)

Generation runs with --extra-fields=allow, so every generated model was ConfigDict(extra="allow"). Unknown keys were silently retained in model_extra instead of being rejected:

AllowsMultiDestination.model_validate({"shipping": True, "bogus": "x"})  # accepted today

Fix: the post-processor scans the preprocessed schemas for objects with additionalProperties: false and non-empty named properties, maps each to its generated class (root title or the nested property path, e.g. allows_multi_destination -> AllowsMultiDestination), and flips that class's model_config to extra="forbid". Sibling classes in the same module keep extra="allow".

Category (Required)

  • Core Protocol: Changes to the core UCP specification. (Requires Technical Council approval)
  • Governance/Contributing: Changes to governance or contributing processes. (Requires Governance Council approval)
  • Capability: Changes to a UCP capability. (Requires Maintainer approval)
  • Documentation: Documentation-only changes. (Requires Maintainer approval)
  • Infrastructure: CI/CD or repository infrastructure changes. (Requires DevOps Maintainer approval)
  • Maintenance: Dependency or repository maintenance. (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. (Requires Maintainer approval)
  • Community Health (.github): Changes to organization community health files. (Requires DevOps Maintainer approval)

Related Issues

N/A

Checklist

  • I have followed the Contributing Guide and Code of Conduct.
  • 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.
  • 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 (SDK 0.4.x targets UCP release/2026-04-08).

Screenshots / Logs (if applicable)

  • ./generate_models.sh 2026-04-08: postprocess reports extra=forbid on 'AllowsMultiDestination' and extra=forbid on 'ErrorResponse'
  • python -m unittest discover -s tests -p 'test_*.py': 67 passed
  • 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 12, 2026
@damaz91
damaz91 force-pushed the fix/enforce-additional-properties-false branch from 4ec2a57 to 590855c Compare August 12, 2026 10:07
@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Aug 12, 2026
@damaz91
damaz91 merged commit a0d8308 into Universal-Commerce-Protocol:main Aug 12, 2026
16 checks passed
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.

2 participants