Repository navigation
chat@4.44.0
Minor Changes
-
49e6833: Add
BaseFormatConverter.parseIncoming(), which returns a message'stextandformattedAST from a single markdown parse. Very long text can be slow to parse, so text longer thanmaxIncomingParseLength(defaultDEFAULT_MAX_INCOMING_PARSE_LENGTH, 16,384 characters) skips parsing:textholds the raw input andformattedholds it as a single text node. Subclasses can overridemaxIncomingParseLength.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 informatted. In Teams,textfor 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-markdown2.1.0 and of large tables inmicromark-extension-gfm-table2.1.2. Both are within the ranges Chat SDK's dependencies already accept, so update them in your lockfile to pick up the fixes. Keepmicromarkat 4.0.2, since 4.0.3 slows down parsing of block quotes, nested lists, and setext headings.
Patch Changes
-
b8b6f0f:
requestApproval()fromchat/workflownow verifies each click server-side instead of reading the decision and user from the webhook request. When a button with acallbackUrlis 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 asreceipt.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 outsideapproversclicks,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
Chatinstance that handles the click and the one running the workflow must share a state adapter, andrequestApproval()now throws when passed aThreadthat wasn't created by Chat SDK. Errors logged when a callback URL POST fails now include only the URL's origin, undercallbackOrigininstead ofcallbackUrl. -
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 8www.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 whentoAst()throws aRangeError. When any limit is hit, the text is kept verbatim in a single text node. Converters can overrideincomingFallbackText()to clean up that text, andexceedsIncomingBudget()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 GitHublistThreadsfor pull request titles. These adapters didn't limit inbound length before, so messages over 16,384 characters now also lose markdown structure informatted, while keeping their content intext. 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.renderListkeeps 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 under1., 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 newindentListContinuationLinesproperty 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