Fix invalid_blocks: reject numeric-only emoji shortcodes - #7
Closed
presmihaylov wants to merge 12 commits into
Closed
Fix invalid_blocks: reject numeric-only emoji shortcodes#7presmihaylov wants to merge 12 commits into
presmihaylov wants to merge 12 commits into
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tables previously rendered as ASCII art inside code-fenced SectionBlocks, which wrapped poorly for long cell values. Slack's native TableBlock (added Aug 2025) provides per-column wrapping and alignment. This change upgrades slack-go to v0.18.0 and rewrites table rendering to use it. Cells are now *RichTextBlock, so inline formatting (bold, links, code) is preserved automatically instead of being stripped to plain text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Empty cells now get a minimal RichTextSection instead of producing "elements": null which the Slack API would reject - Update Go version requirement from 1.22+ to 1.25+ in CLAUDE.md, README.md, and DEMO.md to match go.mod - Fix stale doc.go prose still referencing SectionBlock for tables - Update README.md table mapping for GFM tables - Add TestConvert_TableEmptyCell test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Slack rejects messages with more than one table (only_one_table_allowed). ChunkBlocks now forces a new chunk before every additional TableBlock, in addition to the existing maxPerMessage split. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add nil guard to emitBlock to prevent appending nil blocks - Reset style stack at table cell entry to prevent style leaking - Document ChunkBlocks table-per-chunk enforcement in README - Add tests for multiple tables, mixed blocks, and code-in-cell Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Incorporates upstream feat/native-table-block changes (GFM tables now render as native Slack TableBlocks with rich text cells and per-column alignment). Fixes empty cell handling — Slack API rejects empty string text elements, so use a space instead. Updates module path to fork. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Slack's rich_text blocks require emojis as explicit RichTextSectionEmojiElement objects — plain text shortcodes like 📊 are rendered literally. Goldmark's emphasis parser also splits text at underscores, fragmenting shortcodes across multiple text elements. Add post-processing in resolveEmojis() that merges adjacent text elements with the same style and converts detected :emoji_name: patterns into proper emoji elements. Applied in flushInlineToSection(), paragraph emission, and blockquote accumulation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Convert emoji shortcodes to native Slack emoji elements
Slack's TableBlock API enforces a maximum of 100 rows (including header) and 20 columns per table. Previously, md2slack would emit a single TableBlock regardless of size, causing Slack to reject the message with `invalid_blocks`. Split oversized tables into multiple TableBlocks, each carrying the same header row. Columns beyond 20 are silently truncated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enforce Slack TableBlock row and column limits
Time strings like `19:49:41` in inline code were being split into false emoji matches (`:49:` → emoji element with name "49"), causing Slack to reject the entire message with `invalid_blocks`. Add isValidEmojiName check requiring at least one letter in the emoji name, which correctly excludes numeric-only patterns while preserving valid emojis like `:+1:`. Co-Authored-By: Claude Opus 4.6 <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.
Summary
19:49:41in inline code were being split into false emoji matches (:49:→ emoji element with name "49"), causing Slack to reject the entire message withinvalid_blocksisValidEmojiName()check requiring at least one letter in the emoji name, which correctly excludes numeric-only patterns while preserving valid emojis like:+1:Root Cause
The emoji shortcode regex
:[a-z0-9+][a-z0-9_+\-]*:matched pure-digit patterns like:49:and:50:extracted from timestamps. Slack's API rejects these as invalid emoji element names since no such emojis exist.Test plan
:bar_chart:,:+1:,:wave:, etc.)10:30:00,23:59:59) not treated as emoji🤖 Generated with Claude Code