Skip to content

fix(slack-bot): stop empty arg values from breaking the approval card - #1987

Merged
JAORMX merged 1 commit into
mainfrom
fix/slack-bot-approval-card-empty-args
Sep 29, 2026
Merged

JAORMX merged 1 commit into
mainfrom
fix/slack-bot-approval-card-empty-args

Conversation

@kantord

@kantord kantord commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

  • An empty-string arg key or value rendered as a Block Kit rich_text text leaf with zero characters, which Slack rejects outright as invalid_blocks. Per the gateway's fail-closed design (slack-bot: DM manual permission approvals instead of auto-approving #1707), that meant every real permission ask silently denied instead of ever reaching the user. Confirmed live in a --posture strict deployment (stacklok/infra#5844). Fixes slack-bot: approval-card blocks fail Slack's schema validation (invalid_blocks) #1986.
  • Adds a cache-backed regression suite instead of a hand-rolled invariant: fixtures/blocksValidateCases.ts lists named edge-case inputs, record-blocks-validate-cache.ts validates them once against Slack's real blocks.validate API and writes the result to fixtures/blocksValidateCache.json, and approvals.blocksValidate.test.ts cross-checks current code against that cache on every run - offline, but grounded in genuine Slack-validated ground truth rather than an assumption this repo wrote itself. If current code renders a case's blocks differently than what's cached, the test fails loudly (never silently trusts new output).

Why draft

fixtures/blocksValidateCache.json isn't included yet - it needs a live SLACK_BOT_TOKEN to generate (blocks.validate has no side effect, doesn't post anywhere, any workspace's token works):

cd sdk/typescript/examples/slack-bot
SLACK_BOT_TOKEN=xoxb-... pnpm record:blocks-validate

That writes the cache file, which then needs to be committed before this is ready for real review. Until then, approvals.blocksValidate.test.ts skips cleanly (visible as 36 skipped cases) rather than failing.

Test plan

  • pnpm test in sdk/typescript/examples/slack-bot - 79 passed, 36 skipped (the cache-backed suite, pending the cache file)
  • pnpm typecheck / pnpm lint - no new errors introduced
  • Manually reverted the fix and confirmed the regression test (and, separately, a property-based one since removed in favor of the cache approach) actually catches the bug - shrinks to {"":""} in one step
  • Run pnpm record:blocks-validate with a live token and commit the resulting cache file
  • Confirm the fix live against a real Slack workspace (a real permission ask now delivers and is clickable)

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

An empty-string arg key or value rendered as a rich_text text leaf with
zero characters, which Slack rejects outright as invalid_blocks. Per
the gateway's fail-closed design, that meant every real permission ask
silently denied instead of ever reaching the user (mecatl#1986).

Render an empty string as a literal "" instead of leaving it empty.

Also adds a cache-backed regression suite: a named set of edge-case
inputs (fixtures/blocksValidateCases.ts) gets validated once against
Slack's real blocks.validate API (test/record-blocks-validate-cache.ts,
requires a live token, run manually) and cached to disk, so day-to-day
test runs cross-check current code against real Slack-validated ground
truth with no network calls. The cache file itself isn't included yet -
run `pnpm record:blocks-validate` with a live SLACK_BOT_TOKEN once to
generate it.

Fully or partially written by an AI agent.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord
kantord marked this pull request as ready for review September 28, 2026 14:37
@JAORMX
JAORMX merged commit 3261c4f into main Sep 29, 2026
61 of 71 checks passed
@JAORMX
JAORMX deleted the fix/slack-bot-approval-card-empty-args branch September 29, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slack-bot: approval-card blocks fail Slack's schema validation (invalid_blocks)

2 participants