Skip to content

Fix Discord embed author name length validation using wrong limit - #74940

Merged
shahar1 merged 1 commit into
apache:mainfrom
udsy19:fix/discord-embed-author-name-limit
Oct 18, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
udsy19:fix/discord-embed-author-name-limit

Conversation

@udsy19

@udsy19 udsy19 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Why

DiscordCommonHandler.validate_embed checks the embed author name against a > 2048 limit, but Discord's documented embed author-name limit is 256 — and the error message on the very next line already says "256 or fewer characters":

if "author" in embed:
    if len(embed["author"]["name"]) > 2048:   # should be 256
        raise ValueError("Discord embed author name must be 256 or fewer characters")

The 2048 was copied from the footer-text check directly above (where 2048 is correct). Every sibling 256-char check (title, field name) correctly uses > 256; only author.name was wrong.

validate_embed exists to reject oversized embeds locally with a clear message before the webhook call. With the wrong bound, an author name of 257–2048 characters silently passes local validation and is instead rejected downstream by Discord's API with a less helpful error — defeating the purpose of the local check and contradicting both the function's own error text and the Discord embed-limits spec it cites.

What

> 2048 → > 256 for the author name.

Tests

The existing parametrized fail-on-author-name case used "t" * 2049, which exceeds even the buggy 2048 bound and so never exercised the defect. Tightened to "t" * 257 (limit + 1), matching the sibling 256-limit cases. Verified fail-on-revert on the real validate_embed: a 257-char name is rejected only after the fix (256 is accepted at the boundary); reverted, the 257-char name passes.

DiscordCommonHandler.validate_embed checked the author name against a
2048-character limit, but Discord's embed author name limit is 256 (and
the error message already says "256 or fewer characters"). The 2048 was
copied from the footer-text check, where 2048 is correct. As a result an
author name of 257-2048 characters passed local validation and was only
rejected later by Discord's API with a less helpful error.

The existing regression test used a 2049-character name, which happened
to exceed even the wrong bound and so never caught the defect; tighten it
to 257 to match the 256 limit, consistent with the sibling title and
field-name cases.

Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@shahar1
shahar1 merged commit ae8c970 into apache:main Oct 18, 2026
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants