test(conformance): accept compliant 4xx error responses in validation test - #67
Merged
damaz91 merged 4 commits intoJul 28, 2026
Conversation
damaz91
force-pushed
the
feat/discount-conformance
branch
from
July 27, 2026 09:08
a08bcba to
d8beabf
Compare
… 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
force-pushed
the
feat/discount-conformance
branch
from
July 27, 2026 09:12
d8beabf to
8f89ac5
Compare
Applying code review recommendation to check all errors instead of just the first one. TAG=agy CONV=46bf6a0b-350d-4fc9-8de0-233576567b08
nicholasjameshall
approved these changes
Jul 27, 2026
| data.get("detail"), "Error response missing 'detail' field" | ||
| ) | ||
| self.assertIn("stock", str(data["detail"]).lower()) | ||
| if "messages" in data: |
There was a problem hiding this comment.
just wondering if we should be testing the raw json object or whether we should try to cast to the appropriate dataclass first?
Contributor
Author
There was a problem hiding this comment.
good callout. i'll update this one and all others as well
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
carolinerg1
approved these changes
Jul 27, 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
Update
test_structured_error_messagesinvalidation_test.pyto accept compliant UCP error responses (carryingmessagesarray) in addition to legacy FastAPI responses (carryingdetailfield).Category (Required)
Please select one or more categories that apply to this change.
ucp-schematool (resolver, linter, validator). (Requires Maintainer approval)Related Issues
Checklist
!for breaking changes).Screenshots / Logs (if applicable)