Skip to content

fix(slack): scope invalid_blocks fix to pre-formatted mrkdwn replies - #1797

Closed
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/slack-auth-pause-invalid-blocks
Closed

fix(slack): scope invalid_blocks fix to pre-formatted mrkdwn replies#1797
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/slack-auth-pause-invalid-blocks

Conversation

@sentry

@sentry sentry Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the SlackActionError: An API error occurred: invalid_blocks error originating from postAuthPauseNotice (JUNIOR-72).

Root Cause:
The buildAuthPauseResponse function 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 to sendSlackReply and subsequently rendered within a { type: "markdown" } block, Slack's internal markdown-to-rich_text converter incorrectly assigned a url property to non-link rich_text inline elements. This violation of Slack's block schema caused the API to reject the message with invalid_blocks.

Why the previous approach (PR #1797) was reverted:
The initial fix in PR #1797 broadly changed all reply bodies from markdown blocks to section/mrkdwn blocks. 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 the markdown block type.

Solution:
This PR implements a more targeted fix by introducing a bodyFormat option ("commonmark" as default, "mrkdwn" as opt-in) to buildSlackReplyBlocks and sendSlackReply:

  • buildSlackReplyBlocks now uses a { type: "markdown" } block by default for "commonmark" formatted text.
  • When bodyFormat: "mrkdwn" is specified, it uses a { type: "section", text: { type: "mrkdwn", text } } block.
  • The postAuthPauseNotice function (and its helper postSlackMessageBestEffort in resume.ts) now explicitly passes bodyFormat: "mrkdwn" when sending auth pause messages. This ensures that pre-formatted mrkdwn text bypasses Slack's problematic markdown-to-rich_text conversion, resolving the invalid_blocks error without affecting standard CommonMark rendering for other agent replies.

Testing:

  • Updated packages/junior/tests/unit/slack/footer.test.ts to reflect the new bodyFormat parameter 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 run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 8, 2026 12:56am UTC

Request Review

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sentry-junior sentry-junior Bot closed this Sep 8, 2026
@sentry sentry Bot changed the title fix(slack): prevent invalid_blocks from auth pause notice fix(slack): scope invalid_blocks fix to pre-formatted mrkdwn replies Sep 8, 2026
@sentry sentry Bot reopened this Sep 8, 2026
@sentry
sentry Bot marked this pull request as ready for review September 8, 2026 00:57
@sentry
sentry Bot requested a review from dcramer September 8, 2026 00:57
@github-actions github-actions Bot added the risk: high PR risk score: high label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant