Skip to content

fix: handle URL-encoded @me in /users/:user_id route#1526

Open
xqliu wants to merge 1 commit intospacebarchat:masterfrom
xqliu:fix/users-me-url-decode
Open

fix: handle URL-encoded @me in /users/:user_id route#1526
xqliu wants to merge 1 commit intospacebarchat:masterfrom
xqliu:fix/users-me-url-decode

Conversation

@xqliu
Copy link

@xqliu xqliu commented Feb 15, 2026

Summary

  • /users/%40me returns 404 because %40me (URL-encoded @me) is routed to /users/:user_id instead of the literal /users/@me route
  • Express automatically decodes %40@, so req.params.user_id becomes "@me", but the handler passes it directly to User.getPublicUser() which fails
  • Add the same @me → req.user_id substitution that other :user_id routes already have (e.g. profile.ts, voice-states)

Fixes #1525

Test plan

  • GET /users/%40me returns the authenticated user (same as GET /users/@me)
  • GET /users/<snowflake> still works as before
  • Existing /users/@me/ literal route still works

When clients URL-encode the @ character, /users/%40me is routed to
/users/:user_id instead of the literal /users/@me route. Add the same
@me → req.user_id substitution that other :user_id routes already have
(e.g. profile.ts, voice-states).

Fixes spacebarchat#1525
@TheArcaneBrony
Copy link
Member

Is this AI-generated...?
This route is implemented as /users/@me explicitly rather than /users/:id (different user projections)

@oh64
Copy link
Contributor

oh64 commented Feb 15, 2026

image

@TheArcaneBrony
Copy link
Member

Honestly unsure how this was missed when the users directory only contains 2 directories.

image

@TheArcaneBrony
Copy link
Member

Oh wait, i see the logic now behind picking the "wrong" directory now... but i'm also not sure if this is the right fix, given this would probably affect hundreds of other endpoints.
On the other hand, I also havent seen this issue happen in practice.

@oh64
Copy link
Contributor

oh64 commented Feb 15, 2026

Discord treats %40me as an invalid ID and returns 404
Actually, Discord treats it normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API rejects /users/%40me — should treat %40 as equivalent to @

3 participants