Fix surrogate values in hook tracing#702
Open
almondsun wants to merge 1 commit into
Open
Conversation
Co-authored-by: OpenAI Codex <codex@openai.com>
almondsun
marked this pull request as ready for review
July 21, 2026 18:50
yangfan-yf-yf
approved these changes
Jul 25, 2026
yangfan-yf-yf
left a comment
There was a problem hiding this comment.
Reviewed b7179b9 independently.
The change keeps structural trace labels on str() while applying repr() only to arbitrary traced values, so surrogate characters are escaped without changing the label format. The two regression tests cover both kwargs and hook-result paths.
Validation on Windows with Python 3.12:
python -m pytest? 141 passedgit diff --check? clean
The GitHub test matrix and pre-commit checks are also passing.
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
reprwhile preserving structural labelsreprat thePluginManagerboundaryCloses #681.
Root cause and impact
Tracing formatted arbitrary Python values with
str, which could leave literalsurrogate characters in the resulting message. Writers using ordinary UTF-8
encoding then raised
UnicodeEncodeError. Applyingrepronly at the two valuepositions safely escapes surrogates without quoting trace labels or double-
representing unrelated structural content.
Validation
uv run pytest testing/test_tracer.py testing/test_pluginmanager.py::test_hook_tracing testing/test_pluginmanager.py::test_hook_tracing_safely_formats_surrogate_result— 8 passeduv run pytest— 141 passeduv run pre-commit run -a— all hooks passed, including Ruff, Flake8, MyPy, formatting, and ReST checksgit diff --checkI used Codex as an implementation assistant, reviewed and validated the complete
change, and take responsibility for the contribution and follow-up.