fix(admin): restore digit match in discordId route validation #96
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/discord-id-validation-regex"
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?
Problem
The
:discordIdparam validator on the admin moderation routes uses/^d{1,32}$/, which matches 1–32 literaldcharacters, not digits. A real numeric Discord snowflake (e.g.123456789012345678) fails validation, so every/moderation/user/:discordId*endpoint returns400for valid input. This is live inmainand deployed.Affected routes (all 5 occurrences in
admin.routes.js):GET /moderation/user/:discordIdGET /moderation/user/:discordId/actionsGET /moderation/user/:discordId/notesPOST /moderation/user/:discordId/notesGET /moderation/user/:discordId/appealsCause
The backslash was dropped in a prior code-smell cleanup (
12d50fd, "resolve SonarQube code smells") that intended to rewrite[0-9]→\dbut producedd.Fix
Restore
\dso the regex matches digits again.Verified:
/^\d{1,32}$/accepts123456789012345678, rejectsddd, empty, and 33-digit overflow. No Swagger regen needed (the regex is not part of the#swagger.*annotations). No other dropped-backslash regexes exist elsewhere inserver/,client/, orbot/.AI-assisted: this change was authored with Claude Code.
🤖 Generated with Claude Code
The `:discordId` param validator on the five admin moderation routes used `/^d{1,32}$/`, which matches 1-32 literal `d` characters instead of digits. A real numeric Discord snowflake failed validation, so every `/moderation/user/:discordId*` endpoint returned a 400 for valid input. The backslash was dropped in a prior code-smell cleanup (12d50fd) that intended `[0-9]` -> `\d`. Restore `\d` so the regex matches digits again. Co-Authored-By: Claude <noreply@anthropic.com>