Slack adapter: cardToBlockKit sends headers over 150 chars, so Slack rejects the message
Maintainers usually reply within 1 day
A pull request for this has already been merged.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- api
Research direction
Start in cardToBlockKit in the Slack adapter (the issue cites dist/index.js, so check whether the source file under src is the one to edit). It builds the header, section and button text fields without length limits. Run the repro with a 400-character title and a 5000-character text child, then confirm the header is cut to 150, section text to 3000 and button labels to 75. Done means the truncated blocks are accepted by Slack's limits, the cut ends in an ellipsis, and surrogate pairs are not split.
Written by the indexing model from the issue text.
Description
What happens
cardToBlockKit in @chat-adapter/slack (dist/index.js) puts card.title in a header block, a text child in a section, and button labels in button elements, without checking Slack's limits. A card whose title is over 150 characters, whose text is over 3000, or whose button label is over 75 fails as a whole message:
invalid_blocks: must be less than 151 characters [json-pointer:/blocks/0/text/text]
Checked on 4.39.0 and 4.41.1.
Repro
import { cardToBlockKit } from "@chat-adapter/slack";
const blocks = cardToBlockKit({ type: "card", title: "q".repeat(400), children: [{ type: "text", content: "b".repeat(5000) }] });
// blocks[0].text.text.length === 400; posting these blocks with chat.postMessage returns invalid_blocks
Suggested fix
Cut header text to 150, section text to 3000 and button text to 75, ending in "…", and back up one unit when the cut would split a surrogate pair (emoji). Callers that need the full text can still put it in the body. This came from Paperclip, which hit it with long agent questions: https://github.com/paperclipai/paperclip/issues/15647
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 329
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 61
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel/chat
-
# [@chat-adapter/teams] Adaptive-card button clicks return an empty invoke response → Teams shows "Unable to reach app" and retries the invoke (duplicate action delivery)Possibly taken @ShobhanKarthish claimed this 43 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 40/100
Maintainers usually reply within 1 day
Similar issues
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)Possibly taken @Jxxunnn claimed this today. OpenBrowser Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
getsentry/sentry-javascript#25497 · 1 comment ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
redhat-developer/rhdh-plugin-export-overlays#4438 · 1 comment ·
Maintainers usually reply within 1 day
-
resource: destroying a resource calls AbortController.abort() without a reason, creating an AbortError with a stack trace each timePossibly taken A pull request linked to this issue is open or already merged. Openarea: core
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
angular/angular#71422 · 1 comment ·
Maintainers usually reply within 1 day
-
bug status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
facebook/docusaurus#12739 · 1 comment ·
Maintainers usually reply within 1 day
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day