fix(slack): scope invalid_blocks fix to pre-formatted mrkdwn replies - #1797
Closed
sentry[bot] wants to merge 2 commits into
Closed
fix(slack): scope invalid_blocks fix to pre-formatted mrkdwn replies#1797sentry[bot] wants to merge 2 commits into
sentry[bot] wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Closing in favor of #1798: this PR's approach (switching every reply body from the markdown block to section/mrkdwn) fixes the reported invalid_blocks error but regresses CommonMark rendering (bold, links, tables, headers) for normal agent replies, and breaks 5 existing contract/component tests that assert the markdown block. #1798 scopes the mrkdwn body format to the auth-pause notice path only, which is where the pre-formatted mrkdwn text (<@user> mentions, <url> links) actually originates.
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.
This PR addresses the
SlackActionError: An API error occurred: invalid_blockserror originating frompostAuthPauseNotice(JUNIOR-72).Root Cause:
The
buildAuthPauseResponsefunction generates text that is already pre-formatted as Slack mrkdwn (e.g.,<@user>mentions,<url>angle-bracket links, single-*emphasis). When this text was passed tosendSlackReplyand subsequently rendered within a{ type: "markdown" }block, Slack's internal markdown-to-rich_text converter incorrectly assigned aurlproperty to non-link rich_text inline elements. This violation of Slack's block schema caused the API to reject the message withinvalid_blocks.Why the previous approach (PR #1797) was reverted:
The initial fix in PR #1797 broadly changed all reply bodies from
markdownblocks tosection/mrkdwnblocks. This regressed CommonMark rendering (e.g., bold, links, tables, headers) for standard agent replies and broke several existing contract/component tests that specifically asserted the use of themarkdownblock type.Solution:
This PR implements a more targeted fix by introducing a
bodyFormatoption ("commonmark"as default,"mrkdwn"as opt-in) tobuildSlackReplyBlocksandsendSlackReply:buildSlackReplyBlocksnow uses a{ type: "markdown" }block by default for"commonmark"formatted text.bodyFormat: "mrkdwn"is specified, it uses a{ type: "section", text: { type: "mrkdwn", text } }block.postAuthPauseNoticefunction (and its helperpostSlackMessageBestEffortinresume.ts) now explicitly passesbodyFormat: "mrkdwn"when sending auth pause messages. This ensures that pre-formatted mrkdwn text bypasses Slack's problematic markdown-to-rich_text conversion, resolving theinvalid_blockserror without affecting standard CommonMark rendering for other agent replies.Testing:
packages/junior/tests/unit/slack/footer.test.tsto reflect the newbodyFormatparameter and to include a regression test case for URL-containing text with the"mrkdwn"format, ensuring correct block generation.Fixes JUNIOR-72
Fixes JUNIOR-72
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.