Skip to content

fix(notifications): split Discord issue batches over 2,000 characters - #367

Open
Furox-Art wants to merge 1 commit into
tscircuit:mainfrom
Furox-Art:discord-2000-char-limit
Open

fix(notifications): split Discord issue batches over 2,000 characters#367
Furox-Art wants to merge 1 commit into
tscircuit:mainfrom
Furox-Art:discord-2000-char-limit

Conversation

@Furox-Art

Copy link
Copy Markdown

Closes #359

Problem

notifyDiscord() joins every new issue for a repository into a single content string and sends it with no length check. Discord rejects webhook payloads over 2,000 characters, and a batch of ~30 issues with ordinary-length titles already exceeds that. A rejected send also escapes the sequential repository loop in main(), so later repositories are not notified in that run.

Fix

  • New helper lib/utils/splitDiscordContent.ts: splits content into chunks of at most 2,000 characters.
    • Lines are kept whole whenever they fit, so issue entries stay readable.
    • A single line that cannot fit is split on a boundary that never breaks a UTF-16 surrogate pair.
    • Joining the chunks with \n reproduces the input, so no notification is silently dropped.
  • notifyDiscord() now sends the chunks sequentially, preserving allowedMentions: { parse: [] } (no link previews) and the existing failure semantics — a transport failure still propagates, with no automatic retry.

Scope is deliberately narrow: main()'s error handling is unchanged.

Validation

  • New tests/test-discord-content-splitting.test.ts — 8 cases: empty content, below limit, exactly at the limit, one over, the 30-issue batch from the issue (every entry preserved, every chunk within the limit), a surrogate pair at the boundary, a single over-long line, and multiline content.
  • Full suite: 65 passed / 0 failed (bun 1.4.2).
  • tsc --noEmit clean, biome format clean on the touched files.

Disclosure: this PR was prepared with AI assistance (implementation and tests), reviewed and validated locally.

Discord rejects webhook payloads whose content exceeds 2,000 characters, and a batch of roughly 30 new issues already passes that limit. The rejected send also escaped the sequential repository loop in main(), so later repositories were not notified in that run.

notifyDiscord() now splits the message at line boundaries, falling back to a bounded split that never breaks a UTF-16 surrogate pair, and sends the chunks sequentially. allowedMentions: { parse: [] } and the existing failure semantics are preserved.

Closes tscircuit#359
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

@Furox-Art is attempting to deploy a commit to the tscircuit 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.

Issue notifications can exceed Discord’s 2,000-character content limit

1 participant