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

Aperta
#43,327 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mrityunjay-pandey ci sta già lavorando.

Dal 30/10/2026.

  • #43328 di @mrityunjay-pandey — aperta
  • #43388 di @sudoKrishna — aperta
  • #43450 di @sisodiaumang — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
mongodb, typescript
Ambito
databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
Lingua principale
TypeScript
Stelle
46.5k
Fork
14.1k
Merge medio
1g 21h
PR unite (30g)
381

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RocketChat/Rocket.Chat

Tutte le issue di RocketChat/Rocket.Chat

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.