Skip to content

fix(discord): sanitize autocomplete choices#830

Open
ugcodrr wants to merge 1 commit intomainfrom
fix-autocomplete-choice-names
Open

fix(discord): sanitize autocomplete choices#830
ugcodrr wants to merge 1 commit intomainfrom
fix-autocomplete-choice-names

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented Apr 12, 2026

Fixes the Sentry error where Discord rejects autocomplete responses with Invalid Form Body | data.choices[n].name - BASE_TYPE_BAD_LENGTH.

This sanitizes autocomplete choices at the shared Discord response boundary before replying:

  • Drops empty or whitespace-only choice names.
  • Drops empty/whitespace-only string values and overlong string values.
  • Trims displayed choice names and caps them to Discord's 100-character limit.
  • Caps autocomplete responses to Discord's 25-choice limit.

This covers the observed status command/player search case where a raw whitespace query could be appended as an autocomplete choice.

Checks run:

  • pnpm --filter @statsify/discord test:types
  • pnpm --filter @statsify/discord lint
  • pnpm --filter discord-bot test:types
  • git diff --check

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
statsify Ready Ready Preview, Comment Apr 12, 2026 0:55am

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.

1 participant