RocketChat / RocketChat/Rocket.Chat

Inconsistent return type in parseUriList leads to incorrect OAuth redirectUri handling

Open Beginner friendly
#39,762 2 comments 0 reactions 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

What: parseUriList(userUri) returns a string instead of a consistent array type.

Where: parseUriList.ts (used by updateOAuthApp and addOAuthApp)

Problem:
Callers expect an array-like redirectUri (e.g., checking .length, storing in DB). Returning a string may pass some checks but leads to incorrect runtime behavior and inconsistent DB schema (string vs array).


Steps to Reproduce
  1. Call parseUriList('https://example.com') → returns a string
  2. Call parseUriList('https://a.com,https://b.com') → returns a comma-separated string
  3. Observe incorrect handling in OAuth flows

Impact
  • Subtle runtime bugs
  • Inconsistent database entries
  • Issues in OAuth redirect validation

Expected Behavior

parseUriList should always return string[]:

  • Empty input → []
  • Single URI → ['uri']
  • Multiple URIs → ['uri1', 'uri2']

Possible Solution

Update parseUriList to always return an array of trimmed URIs.
Add unit tests for empty, single, and multiple inputs.
(Optional) Migrate existing string values in DB to arrays.

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 in parseUriList.ts and trace its use from updateOAuthApp and addOAuthApp. Verify the current behavior for empty, single, and comma-separated URI inputs, then add unit tests covering those cases. Done means parseUriList consistently returns trimmed string arrays and the OAuth callers handle redirectUri with that shape.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.