Conversation
`parameterize` built the message with `String.raw`, so an escape such as `\n` or `` \` `` stayed as a backslash sequence in the log body or event message, while the template attribute used the cooked strings. A string with an invalid escape sequence (e.g. a Windows path) has no cooked value, so its text dropped out of the template entirely. Build both from the cooked strings, falling back to the raw string where there is no cooked value. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
parameterize(exported asSentry.logger.fmt) builds the message withString.raw(strings, ...values), which uses the raw strings. The template it stores uses the cookedstrings. So escape sequences in the literal stay as backslash sequences in the message. For example,logger.info(logger.fmt`Line one\nline two ${x}`)sends the log bodyLine one\nline two ...with a literal backslash-n, and\`or\u2192come out as typed. Meanwhilesentry.message.templateholds the real newline, so the body and the template disagree.The reverse problem hits a string with an invalid escape sequence, such as a Windows path like
fmt`Reading C:\users ${file}`. It has no cooked value, sostrings.jointurned it into an empty string. The template became just%s, both insentry.message.templateand in thelogentry.messagethatcaptureMessagesends.The fix builds both the message and the template from the cooked strings. Where there is no cooked value, it falls back to the raw string. The two new tests fail on
developand pass with this change.yarn lint) & (yarn test).I ran the
packages/corevitest suite with and without the change. The only failures are the same 2 environment failures (zoderrrors,typedef) on both.tsc --noEmitonpackages/coreis clean, and so isoxfmt --checkon the changed files. I also ranoxlinton them, without the@sentry/eslint-plugin-sdkJS plugin.An AI coding agent (Claude Code, run by breken-ai) found this bug and wrote this change. I checked the red/green tests above before opening the PR.
🤖 Generated with Claude Code