Skip to content

fix(adapter-slack): replace empty table cells with single space#327

Open
goofansu wants to merge 1 commit intovercel:mainfrom
goofansu:fix/slack-empty-table-cells
Open

fix(adapter-slack): replace empty table cells with single space#327
goofansu wants to merge 1 commit intovercel:mainfrom
goofansu:fix/slack-empty-table-cells

Conversation

@goofansu
Copy link
Copy Markdown

@goofansu goofansu commented Apr 4, 2026

Summary

Slack's Block Kit API rejects table cells with empty text fields (must be more than 0 characters). When a markdown table contains an empty cell — e.g. a trailing | and more... | | row — the adapter passes text: "" to the API, causing an invalid_blocks error and the message failing to send.

Fixed in two places:

  • packages/adapter-slack/src/markdown.tsmdastTableToSlackBlock: ...join("") || " "
  • packages/adapter-slack/src/cards.tsconvertTableToBlocks: convertEmoji(header) || " " and convertEmoji(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.tstoBlocksWithTable with | and more... | | (the cell that triggered the original crash at blocks/1/rows/15/1). Asserts every cell has length > 0 and the empty cell becomes " ".
  • cards.test.tsconvertTableToBlocks with 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:

[ERROR]  web-api:WebClient:0 failed to match any allowed schemas [json-pointer:/blocks/1/rows/15/1]
[ERROR]  web-api:WebClient:0 must be a valid enum value [json-pointer:/blocks/1/rows/15/1/type]
[ERROR]  web-api:WebClient:0 must be more than 0 characters [json-pointer:/blocks/1/rows/15/1/text]
[ERROR]  web-api:WebClient:0 missing required field: elements [json-pointer:/blocks/1/rows/15/1]
[chat-sdk] Message processing error {
  error: Error: An API error occurred: invalid_blocks
      at platformErrorFromResult (/Users/james/code/pi-chat/node_modules/.pnpm/@slack+web-api@7.15.0/node_modules/@slack/web-api/dist/errors.js:67:33)
      at WebClient.apiCall (/Users/james/code/pi-chat/node_modules/.pnpm/@slack+web-api@7.15.0/node_modules/@slack/web-api/dist/WebClient.js:232:56)
      at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
      at async _SlackAdapter.editMessage (file:///Users/james/code/pi-chat/node_modules/.pnpm/@chat-adapter+slack@4.23.0/node_modules/@chat-adapter/slack/dist/index.js:2571:25)
      at async Object.edit (file:///Users/james/code/pi-chat/node_modules/.pnpm/chat@4.23.0/node_modules/chat/dist/index.js:1669:9)
      at async askPi (file:///Users/james/code/pi-chat/index.ts:258:2)
      at async file:///Users/james/code/pi-chat/index.ts:267:2
      at async Chat.runHandlers (file:///Users/james/code/pi-chat/node_modules/.pnpm/chat@4.23.0/node_modules/chat/dist/index.js:3294:7)
      at async Chat.dispatchToHandlers (file:///Users/james/code/pi-chat/node_modules/.pnpm/chat@4.23.0/node_modules/chat/dist/index.js:3156:7)
      at async Chat.handleQueueOrDebounce (file:///Users/james/code/pi-chat/node_modules/.pnpm/chat@4.23.0/node_modules/chat/dist/index.js:3018:9) {
    code: 'slack_webapi_platform_error',
    data: {
      '0': 'failed to match any allowed schemas [json-pointer:/blocks/1/rows/15/1]',
      '1': 'must be a valid enum value [json-pointer:/blocks/1/rows/15/1/type]',
      '2': 'must be more than 0 characters [json-pointer:/blocks/1/rows/15/1/text]',
      '3': 'missing required field: elements [json-pointer:/blocks/1/rows/15/1]',
      ok: false,
      error: 'invalid_blocks',
      response_metadata: [Object]
    }
  },
  threadId: 'slack:C0AQLMSJVQD:1775264513.393679'
}

Triggered by a table with a trailing empty cell:

| Kind            | Label               |
|-----------------|---------------------|
| FORM            | Form Submission     |
| ...             | ...                 |
| and more...     |                     |

Encounter the problem and fix in this commit: goofansu/pi-chat@1199a1a

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.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 4, 2026

@goofansu is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant