Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Both new tests fail on supported Python 3.11 because Pydantic rejects typing.TypedDict, so they must import it from typing_extensions before they can exercise validation or the diagnostic fallback.
1 open issue
What changed in this PR
This PR addresses #544 by making Python validation return Failure when Pydantic diagnostics contain non-JSON-serializable values, while preserving the original rejected input.
Changes:
- Fall back to
reprwhen diagnostic JSON serialization raisesTypeErrororValueError. - Add regression coverage for bytes diagnostics and a valid-input control.
- Preserve existing formatting for JSON-serializable diagnostics.
| File | Description |
|---|---|
python/tests/test_validator.py |
Adds bytes-diagnostic regression and valid-input tests. |
python/src/typechat/_internal/validator.py |
Adds fallback formatting for non-JSON-serializable diagnostic values. |
Review effort: Balanced
Author
|
@microsoft-github-policy-service agree |
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.

Summary
TypeChatValidator.validate_objectraisesTypeErrorinstead ofreturning
Failurewhen a Pydantic validation diagnostic contains a value that isnot
JSON-serializable — for example
bytesproduced by aBeforeValidator.Before: