fix(adapter-slack): replace empty table cells with single space#327
Open
goofansu wants to merge 1 commit intovercel:mainfrom
Open
fix(adapter-slack): replace empty table cells with single space#327goofansu wants to merge 1 commit intovercel:mainfrom
goofansu wants to merge 1 commit intovercel:mainfrom
Conversation
Slack's Block Kit API rejects cells with empty text fields. Fall back to a single space in both mdastTableToSlackBlock (markdown.ts) and convertTableToBlocks (cards.ts) to satisfy the API constraint.
Contributor
|
@goofansu is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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
Slack's Block Kit API rejects table cells with empty
textfields (must be more than 0 characters). When a markdown table contains an empty cell — e.g. a trailing| and more... | |row — the adapter passestext: ""to the API, causing aninvalid_blockserror and the message failing to send.Fixed in two places:
packages/adapter-slack/src/markdown.ts—mdastTableToSlackBlock:...join("") || " "packages/adapter-slack/src/cards.ts—convertTableToBlocks:convertEmoji(header) || " "andconvertEmoji(cell) || " "Empty cells now fall back to a single space, which satisfies the API constraint.
Test plan
Added a failing test to each affected file that reproduces the exact error, then verified the fix makes them pass:
markdown.test.ts—toBlocksWithTablewith| and more... | |(the cell that triggered the original crash atblocks/1/rows/15/1). Asserts every cell haslength > 0and the empty cell becomes" ".cards.test.ts—convertTableToBlockswith an empty header cell and an empty data cell. Same assertions.Both tests were confirmed red without the fix and green with it.
Original error:
Triggered by a table with a trailing empty cell:
Encounter the problem and fix in this commit: goofansu/pi-chat@1199a1a