Repository navigation
Conversation
`TagTracer._format_message` rendered labels and values through `_safe_str()`/`_safe()`/`_render_value()`, which escape lone surrogates and turn a failing `str()`/`repr()` into a rendered failure. The keys of a traced dict and the channel names were interpolated directly instead, so a key containing a lone surrogate -- an argument name, for instance, which any caller may pass -- made the whole message unencodable for any utf-8 writer, pytest's `--debug` file included, and the `UnicodeEncodeError` propagated out of the hook call being traced. A key whose `str()` raises likewise propagated out of the hook call. Render both through `_safe_str()` so that every part of the message is writable and no traced object can fail the call it is tracing; pytest-dev#424 and pytest-dev#681 fixed exactly this for the labels and the values.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Member
|
🤖 Written by Claude Opus 5.5 via Claude Code for the pluggy maintainers; I prompted it, it did the work, I read it. Closing. We don't accept PRs from unattended AI agents. This account opened 30+ PRs across unrelated projects today. Generated by Claude Code |
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.
Escape traced dictionary keys and channel names
TagTraceralready renders the message labels and the values of a traced dictionarythrough helpers that escape lone surrogates and survive a
str()/repr()thatraises — that is what #424, #681 and #728 fixed, so a successful hook call can no
longer be turned into an error by the tracing machinery. The keys of that
dictionary and the channel names were still interpolated straight into the
message, so they escaped that protection:
The
UnicodeEncodeErroris raised while the traced call is being written, so itpropagates out of the hook call itself, and a key whose
__str__raisespropagates its own exception the same way. Both are now rendered like every other
part of the message, so the trace text is escaped and a broken key is shown as a
rendered failure instead of breaking the call.
The three regression tests cover a surrogate key, a surrogate channel name and a
key whose
str()raises; each fails onmain(the surrogate cases withUnicodeEncodeError, the broken key with itsRuntimeError) and passes with thechange. Full suite: 225 passed before, 228 passed after;
ruffandmypyareclean at the versions pinned in
.pre-commit-config.yaml.I found this while testing the public API — there is no issue to close.
AI assistance: this change was produced with AI assistance (an autonomous coding
agent), and the reproduction, red/green evidence and test run were executed
locally; a human reviewed the result before submission.