[Hardening] Budget Discord embed total size (6000 chars) across all bot embeds #94
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Discord enforces two separate embed limits: the description alone may be up to 4096 characters, but the whole embed (title + description + all field names/values + footer) may not exceed 6000 characters total. Exceeding the total raises
discord.HTTPException(400) and the entire send fails.The bot's embed builders only guard the description:
/recap(bot/questboard_bot/cogs/sessions.py:140-171): truncates the summary to 4000 (session.summary[:4000], line 151) but then adds a "GM Notes" field up to 1000 chars (lines 154-158), a session-date field (line 147), a party-feedback field (lines 160-168), title, and footer. Combined worst case comfortably exceeds 6000 — the whole/recapcommand fails with an HTTP error for long summaries + long notes.summary[:4000]truncation atbot/questboard_bot/cogs/notifications.py:485and:545, each followed by additionaladd_fieldcalls (e.g.:488,:588).Current behavior
A session whose summary is near 4000 chars plus ~1000 chars of GM notes (plus title/fields/footer) produces an embed over 6000 total; the
followup.send(embed=...)raises and the user sees a failed command instead of a truncated recap.Fix / Spec
bot/questboard_bot/utils/(e.g.embed_budget.pyor extend an existing utils module):fit_embed(embed: discord.Embed, max_total: int = 6000) -> discord.Embedor a builder that accepts description + fields and assembles under budget.…)./recap(sessions.py) and both summary embeds (notifications.py:485,:545), replacing the bare[:4000]slices.Acceptance criteria
HTTPException.sessions.pyrecap,notifications.py:485,:545) use the shared helper.References
bot/questboard_bot/cogs/sessions.py:140-171(recap embed assembly;[:4000]at 151, notes field at 154-158)bot/questboard_bot/cogs/notifications.py:485,:545(summary[:4000]descriptions with subsequent fields)Filed from the July 2026 full-project review.
Picking this up as part of a v3.3.0 push. Landing on branch
hardening/bottogether with #83, #85, and #111 (grouped by component to keep the diffs reviewable).Fixed on
main(commitd5866ce, merged viacd315d6). Newbot/questboard_bot/utils/embed_budget.pywithfit_embed(embed, max_total=6000, ...)that counts the whole embed the way Discord does (title + description + every field name/value + footer) and truncates the description last with an ellipsis, while also enforcing description ≤ 4096 and field value ≤ 1024. Applied at all three call sites:/recap(sessions.py) and both summary embeds innotifications.py. Helper unit-tested directly (over-budget total, over-limit description, over-limit field value, under-budget passthrough). Bot suite green (158 passed).