Repository navigation
Conversation
This branch has not been deployed
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.
What
redactTelemetryStringno longer leaves half of a surrogate pair at the cut.truncateTelemetryStringcut atmaxLength - 1UTF-16 code units. When that position fell between the two halves of an astral character (emoji, many CJK extension characters), the kept text ended in a lone high surrogate before the…. That string is not well-formed UTF-16:encodeURIComponentthrowsURIErroron it, andTextEncoder/JSONserialisation turn it intoU+FFFD, so a telemetry or observation message with an emoji near the 240-character limit either breaks the code that sends it or reaches the backend with a replacement character.How
If the last kept code unit is a high surrogate, the cut moves back by one, so the pair is dropped whole. Strings under the limit and cuts that land on a character boundary are unchanged; the result is never longer than
maxLength.Test
New case in
packages/core/src/telemetryRedaction.test.ts: a message of emoji truncated at a limit that falls inside a pair keeps only whole characters and isisWellFormed(). The whole file passes (50 tests). Formatted with oxfmt 0.41.0.fails without the fix:
packages/core/src/telemetryRedaction.test.ts› "does not cut an astral character in half when truncating" (ends in\uD83C…)This PR was prepared with AI assistance; I reviewed the change and ran the tests.