Skip to content

test(conformance): accept compliant 4xx error responses in validation test - #67

Merged
damaz91 merged 4 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/discount-conformance
Jul 28, 2026
Merged

test(conformance): accept compliant 4xx error responses in validation test#67
damaz91 merged 4 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/discount-conformance

Conversation

@damaz91

@damaz91 damaz91 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Update test_structured_error_messages in validation_test.py to accept compliant UCP error responses (carrying messages array) in addition to legacy FastAPI responses (carrying detail field).

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)
  • 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

  • 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)

@damaz91
damaz91 force-pushed the feat/discount-conformance branch from a08bcba to d8beabf Compare July 27, 2026 09:08
… test

Update test_structured_error_messages to accept UcpErrorResponse shape (with 'messages') in addition to legacy/default FastAPI 'detail' shape.

TAG=agy

CONV=66cef4ea-c19e-4693-8c23-b155a5e0cddc
@damaz91
damaz91 force-pushed the feat/discount-conformance branch from d8beabf to 8f89ac5 Compare July 27, 2026 09:12
Applying code review recommendation to check all errors instead of just the first one.

TAG=agy
CONV=46bf6a0b-350d-4fc9-8de0-233576567b08
Comment thread validation_test.py Outdated
data.get("detail"), "Error response missing 'detail' field"
)
self.assertIn("stock", str(data["detail"]).lower())
if "messages" in data:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering if we should be testing the raw json object or whether we should try to cast to the appropriate dataclass first?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good callout. i'll update this one and all others as well

damaz91 added 2 commits July 27, 2026 09:32
Cast the response data to `ErrorResponse` model in `validation_test.py` to ensure it conforms to the UCP schema, rather than just checking raw JSON. Catch `ValidationError` and fail the test if it occurs.

TAG=agy
CONV=46bf6a0b-350d-4fc9-8de0-233576567b08
Refactors `validation_test.py` to use a shared helper `_assert_structured_4xx_error` which casts 4xx responses to the SDK's `ErrorResponse` model.
Updated `assert_business_error` and simplified `test_structured_error_messages` to use it.
Added `assert_4xx_error` helper and used it in `test_complete_without_fulfillment` and `test_payment_failure` to validate the error response structure of direct 4xx rejections.

TAG=agy
CONV=46bf6a0b-350d-4fc9-8de0-233576567b08
@damaz91 damaz91 added status:needs-triage Signal that the PR is ready for human triage status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Jul 27, 2026
@damaz91
damaz91 merged commit c8b20c4 into Universal-Commerce-Protocol:main Jul 28, 2026
15 checks passed
@damaz91
damaz91 deleted the feat/discount-conformance branch July 28, 2026 07:46
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.

4 participants