Skip to content

chat@4.44.0

Choose a tag to compare

@github-actions github-actions released this 02 Nov 14:55
· 48 commits to main since this release
9476152

Minor Changes

  • 49e6833: Add BaseFormatConverter.parseIncoming(), which returns a message's text and formatted AST from a single markdown parse. Very long text can be slow to parse, so text longer than maxIncomingParseLength (default DEFAULT_MAX_INCOMING_PARSE_LENGTH, 16,384 characters) skips parsing: text holds the raw input and formatted holds it as a single text node. Subclasses can override maxIncomingParseLength.

    The Discord, Google Chat, GitHub, GitLab, and Teams adapters now use parseIncoming() for incoming messages, so they parse each message once instead of twice. Messages over the limit keep their content but lose markdown structure in formatted. In Teams, text for such a message also keeps the raw HTML tags, and in GitLab a mention inside a code block or quote in such a note counts as a mention.

    Upstream releases fix slow parsing of long lists in mdast-util-from-markdown 2.1.0 and of large tables in micromark-extension-gfm-table 2.1.2. Both are within the ranges Chat SDK's dependencies already accept, so update them in your lockfile to pick up the fixes. Keep micromark at 4.0.2, since 4.0.3 slows down parsing of block quotes, nested lists, and setext headings.

Patch Changes

  • b8b6f0f: requestApproval() from chat/workflow now verifies each click server-side instead of reading the decision and user from the webhook request. When a button with a callbackUrl is clicked, Chat SDK now stores a receipt in the state adapter with the verified action ID, user, thread, and message, and adds its identifier to the callback payload as receipt. requestApproval() takes the decision and user only from that receipt, accepts each receipt once, and ignores requests without a valid one. If the receipt can't be stored, Chat SDK skips the callback POST and restores the button's callback token so the user can click again. When someone outside approvers clicks, requestApproval() now also refreshes the card's buttons, because each button's callback works only once and that click previously left the button unusable for approvers.

    The Chat instance that handles the click and the one running the workflow must share a state adapter, and requestApproval() now throws when passed a Thread that wasn't created by Chat SDK. Errors logged when a callback URL POST fails now include only the URL's origin, under callbackOrigin instead of callbackUrl.

  • d3dc15a: parseIncoming() now skips markdown parsing for more kinds of input that are slow to parse, not just long text. Some messages under the 16,384-character limit took seconds to parse, threw a stack overflow, or produced trees too deep to serialize. Examples include unmatched *, _, or ~ in one paragraph, runs of ] or <, www. repeated within one word, and lines that open hundreds of nested quotes or lists. Before parsing, parseIncoming() now also checks for more than 2,048 *, _, and ~ characters (maxIncomingEmphasisMarkers), more than 128 ] characters (maxIncomingClosingBrackets), more than 512 < characters (maxIncomingAngleBrackets), more than 8 www. links in one word (maxIncomingWwwAutolinks), and lines nested more than 32 deep (maxIncomingContainerMarkers). These checks run in linear time and ignore characters inside fenced code blocks. After parsing, it checks for trees deeper than 128 levels (maxIncomingAstDepth), and it also falls back when toAst() throws a RangeError. When any limit is hit, the text is kept verbatim in a single text node. Converters can override incomingFallbackText() to clean up that text, and exceedsIncomingBudget() to check text they rewrite before parsing.

    The Discord gateway, Instagram, Linear, Messenger, Notion, Slack, Teams history, Telegram, Twilio, Web, WhatsApp, and XChat adapters now build incoming and fetched messages with parseIncoming() instead of parsing them without limits, and so does GitHub listThreads for pull request titles. These adapters didn't limit inbound length before, so messages over 16,384 characters now also lose markdown structure in formatted, while keeping their content in text. Deeply nested quotes no longer make these adapters drop the message, return a server error, or fail a whole page of history.

    Slack checks the limits once across a message's text, blocks, attachments, and table cells, checks the markdown it converts mrkdwn into, and on fallback decodes entities and renders mentions, channels, and links as parsed messages do. Discord, Google Chat, and WhatsApp check the markdown they convert platform text into. Teams checks the limits on decoded text, renders mentions and entities as plain text on fallback, and no longer backtracks for seconds on malformed links in incoming HTML.

  • 6c4457e: BaseFormatConverter.renderList keeps list items together in more cases. A list nested under an ordered item now starts at the item's content column. It used to get two spaces, which is too few under 1. , so the nested items became siblings of their parent. Two blocks in one item, such as two paragraphs, now have a blank line between them instead of merging. A nested ordered list that doesn't start at 1, or a nested list after HTML, also keeps a blank line before it, because it can't follow the block above directly. Converters can also set the new indentListContinuationLines property to indent every line of a multi-line block in an item, such as a code block or a block quote. The Teams converter turns it on, so a code block in a list item no longer falls out of the item.

  • Updated dependencies [6300fe4]

    • @chat-adapter/catalog@4.44.0