mongo-adapter: $pull throws on element conditions and empties the array for a regex or date

Open
#43,327 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@mrityunjay-pandey is already working on this.

Since Oct 30, 2026.

  • #43328 by @mrityunjay-pandey — open
  • #43388 by @sudoKrishna — open
  • #43450 by @sisodiaumang — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
mongodb, typescript
Domain
databases

Research direction

Start with createTransformFromUpdateFilter, the client-side update helper named in the reproduction, and trace how it handles $pull arguments. Check the existing tests around this helper, if available. Done means element conditions, regular expressions, and dates produce the expected arrays; linked pull request #43328 indicates work is already underway.

Written by the indexing model from the issue text.

Description

type: bug
Description:

In @rocket.chat/mongo-adapter (the client-side update helper for local collections), $pull treats every object argument as a query on documents. This breaks three kinds of valid MongoDB $pull arguments:

  • A condition on the elements themselves ({ $gte: 20 }, { $in: [10, 30] }) throws Unrecognized logical operator: $gte.
  • A regular expression (/^tmp/) has no keys, so it compiles to an empty filter and removes every element.
  • A date (new Date(1)) behaves the same way and also removes every element.
Steps to reproduce:
import { createTransformFromUpdateFilter } from '@rocket.chat/mongo-adapter';

createTransformFromUpdateFilter({ $pull: { scores: { $gte: 20 } } })({ scores: [10, 20, 30] }); // throws
createTransformFromUpdateFilter({ $pull: { tags: /^tmp/ } })({ tags: ['tmp-1', 'keep'] }); // { tags: [] }
createTransformFromUpdateFilter({ $pull: { dates: new Date(1) } })({ dates: [new Date(1), new Date(2)] }); // { dates: [] }
Expected behavior:

As in MongoDB: { scores: [10] }, { tags: ['keep'] } and { dates: [new Date(2)] }.

Actual behavior:

The first call throws, and the other two empty the array.

Server Setup Information:
  • Version of Rocket.Chat Server: develop (69a52ce39b)
Dominant language
TypeScript
Stars
46.5k
Forks
14.1k
Avg merge
1d 21h
Merged PRs (30d)
381

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from RocketChat/Rocket.Chat

All issues in RocketChat/Rocket.Chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.