RocketChat / RocketChat/Rocket.Chat

Directory Users search does not ignore leading or trailing whitespace in search term

Open Beginner friendly
#41,545 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

Directory → Users search does not ignore leading or trailing whitespace in the search term.

Searching with leading or multiple trailing spaces fails to find existing users, while searching without extra whitespace works as expected.

Steps to reproduce:
  1. Open DirectoryUsers.
  2. Search for the following terms:
    • preeti
    • preeti
    • preeti
    • preeti
    • preeti
  3. Observe the search results.
Expected behavior:

Leading and trailing whitespace should be ignored during search. The following inputs should all return the same matching user:

  • preeti
  • preeti
  • preeti
  • preeti
  • preeti

Searches containing whitespace within the username (e.g. pre eti) should not return a match.

Actual behavior:

Searches with leading or multiple trailing whitespace do not return matching users, even though the same search without extra whitespace works correctly.

Before fix:

Image
Server Setup Information:
  • Version of Rocket.Chat Server: 8.7.0-develop
  • License Type: Community
  • Number of Users: N/A
  • Operating System: Ubuntu 24.04 (WSL2)
  • Deployment Method: Local development
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 22.22.1
  • MongoDB Version: 7.0.16
Client Setup Information
  • Desktop App or Browser Version: Google Chrome (latest)
  • Operating System: Windows 11
Additional context

The issue only affects Directory → Users search.

Observed behavior:

Search Input Result
preeti ✅ Found
preeti ❌ Not Found
preeti ✅ Found
preeti ❌ Not Found
preeti ❌ Not Found
pre eti ❌ Not Found
Relevant logs:

No relevant server or browser errors were observed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Directory → Users search entry point and reproduce the issue with the listed inputs, including leading, trailing, and internal whitespace. The fix is complete when leading and trailing whitespace produce the same user results as the trimmed term, while whitespace within the username still produces no match.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.