Conversation
What was broken The Slack post for a new support ticket published the member's request body as a single run-on line. Every newline the member typed was collapsed into a space, so paragraphs and list items merged into one sentence: a request written as "Steps I tried:", "- Chrome, incognito", "- Firefox" rendered as "Steps I tried: Chrome, incognito Firefox", which reads as one item and loses the fact that two separate browsers were tried. PM-5863 asked for the notification content to be on multiple lines and for the body of the request to be included, and the body is the part of the message that most needs its own line structure. Root cause markdownNotificationPreview was written for email template data, where the template controls layout, so its final sanitization step collapsed all whitespace with /\s+/g -> ' '. When the Slack request-body preview was added it reused that same helper, inheriting the newline collapsing along with the wanted markdown and URL stripping. What was changed - Split the shared sanitization out of markdownNotificationPreview into a sanitizeMarkdown helper that strips markdown syntax, HTML tags, link targets, and HTML entities while leaving line breaks intact, plus previewLimit and boundPreview helpers for the bound normalization and code-point-safe truncation both previews already needed. - Added markdownNotificationBlockPreview, which collapses only horizontal whitespace, trims each line, and reduces runs of blank lines to a single paragraph break. Embedded URLs and raw markdown are still never published and the preview is still bounded, so the sanitization guarantees are unchanged. - deliverSlack now builds the new-ticket request body with markdownNotificationBlockPreview instead of the single-line preview. - markdownNotificationPreview keeps its exact previous output and remains the helper used for every email template field, so email content is untouched. - Updated the deliverSlack and slackMessage documentation and the README notification section to state that the body preview keeps the author's line and paragraph breaks. Any added/updated tests - notification-outbox.service.spec.ts: a delivery test asserting the opened Slack message carries the request body as its own lines, including the blank paragraph separators and the two list items on separate lines. - notification-outbox.service.spec.ts: unit tests for markdownNotificationBlockPreview covering CRLF input, markdown heading and list marker removal, link targets being stripped, blank-line runs collapsing to one, and bounding that does not split a Unicode code point. - Commands run: pnpm prisma:generate, pnpm lint, pnpm build, pnpm test --runInBand (63 tests, 8 suites passing). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 was broken
The Slack post for a new support ticket published the member's request body as a
single run-on line. Every newline the member typed was collapsed into a space, so
paragraphs and list items merged into one sentence. A request written as:
rendered in Slack as
Steps I tried: Chrome, incognito Firefox, which reads as asingle item and loses the fact that two separate browsers were tried.
PM-5863 asked for the notification content to be on multiple lines and for the
body of the request to be included. The surrounding message lines (headline,
challenge link, ticket link) were already multi-line, but the request body — the
part of the message that most needs its own line structure — was not.
Root cause
markdownNotificationPreviewwas written for email template data, where theemail template controls layout, so its final sanitization step collapsed all
whitespace with
/\s+/gto a single space. When the Slack request-body previewwas added, it reused that same helper and inherited the newline collapsing along
with the wanted markdown and URL stripping.
What was changed
markdownNotificationPreviewinto asanitizeMarkdownhelper that strips markdown syntax, HTML tags, linktargets, and HTML entities while leaving line breaks intact, plus
previewLimitandboundPreviewhelpers for the bound normalization andcode-point-safe truncation that both previews already needed.
markdownNotificationBlockPreview, which collapses only horizontalwhitespace, trims each line, and reduces runs of blank lines to a single
paragraph break. Embedded URLs and raw markdown are still never published and
the preview is still bounded, so the existing sanitization guarantees are
unchanged.
deliverSlacknow builds the new-ticket request body withmarkdownNotificationBlockPreviewinstead of the single-line preview.markdownNotificationPreviewkeeps its exact previous output and remains thehelper used for every email template field, so email content is untouched.
deliverSlackandslackMessagedocumentation and the READMEnotification section to state that the body preview keeps the author's line
and paragraph breaks.
The Slack message now renders as:
Any added/updated tests
notification-outbox.service.spec.ts: a delivery test asserting the openedSlack message carries the request body as its own lines, including the blank
paragraph separators and the two list items on separate lines.
notification-outbox.service.spec.ts: unit tests formarkdownNotificationBlockPreviewcovering CRLF input, markdown heading andlist marker removal, link targets being stripped, blank-line runs collapsing
to one, and bounding that does not split a Unicode code point.
Commands run:
pnpm prisma:generate,pnpm lint,pnpm build,pnpm test --runInBand— 8 suites / 63 tests pass; lint and build are clean.No database migration is needed for this change.
Scope note
The other PM-5863 requirements — the challenge ID as a link to
https://work.topcoder.com/challenges/{challengeId}, multi-line messagecontent, the request body being included at all, and a Slack notification when a
ticket is assigned to a Support Team member — were delivered in #6 and are
already merged to
develop. This PR is the remaining gap in that work.🤖 Generated with Claude Code