RocketChat / RocketChat/Rocket.Chat

`findCustomRoles` in `src/models/Roles.ts` produce "false negative".

Open Beginner friendly
#40,798 0 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

Hi there,
I've found that this specific snippet is producing a false negative on older rocket.chat instances.
https://github.com/RocketChat/Rocket.Chat/blob/85fc0ddca134a875b10133751182eb9c65fd4724/packages/models/src/models/Roles.ts#L139-L145

In my Rocket.Chat instance, I have custom roles set up which are already a few years old.
When looking in the db, they're all missing the protected tag within the db.

I stumbled over this issue, when I wanted to get a specific custom role, but my code failed, saying that it couldn't find the role in question.
Could this code be changed, so that it negates everything? e.g. instead of hard-match protected: false, match for the opposite with the protected: { $ne: true }, I think this should also cover non-existend protected tags like in my case.

Thanks.

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 packages/models/src/models/Roles.ts at the findCustomRoles query around lines 139-145 and inspect how the protected field is matched. Reproduce the lookup with an older custom role that lacks protected, then verify that such roles are returned while roles marked protected still are not.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.