Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.

Fix bot usertype never being assigned - #39

Closed
spktrm wants to merge 1 commit into
smogon:masterfrom
spktrm:fix-bot-usertype
Closed

spktrm wants to merge 1 commit into
smogon:masterfrom
spktrm:fix-bot-usertype

Conversation

@spktrm

@spktrm spktrm commented Oct 15, 2026 •

Copy link
Copy Markdown

Bot accounts (group = 10) are currently sent usertype 2 instead of 10, so the battle server never sets isUserBot (or autoconfirmed) for them.

getAssertion selects only banstate, registertime, logintime, so the destructured group is always undefined and the group === 10 branch added in bac1c6c can never match. TypeScript doesn't flag it because the row type includes group.

The fix adds group to the selected columns, wrapped as a quoted identifier ("${'group'}", as documented in database.ts) so it's escaped for the driver: `group` on MySQL, "group" on Postgres and SQLite. It can't be written inline because it's a reserved word. Bare group is a syntax error in MySQL, and "group" would be read as a string literal without ANSI_QUOTES.

Test

Added Should give bot accounts the bot usertype to actions.test.ts. It registers a user, sets group: 10, logs in and checks the usertype in the assertion. The test config has no signing key, so the test uses a throwaway RSA key and restores the old one afterwards.

  • Without the fix: actual: '2', expected: '10'
  • With the fix: passes
  • eslint and tsc are clean.

The other 8 failures in node --test (userstats, ladder, servertoken and dispatcher tests) fail the same way on master without this change.

getAssertion only selected banstate, registertime and logintime, so
`group` was always undefined and the `group === 10` check never
matched. Bot accounts were sent usertype 2 instead of 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XQgbaPQBwKmTGCy8GuDASp
@spktrm spktrm closed this Oct 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant