[Bug]: Livechat GET /api/v1/livechat/department?enabled=false ignores filter and returns enabled departments

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

I maintainer di solito rispondono entro 1 giorno

@Supriyo760 ci sta già lavorando.

Dal 11/11/2026.

  • #43666 di @Supriyo760 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
mongodb, node.js, typescript
Ambito
api, backend, databases

Direzione di ricerca

Start with apps/meteor/server/api/v1/omnichannel/departments.ts and apps/meteor/server/api/v1/omnichannel/lib/departments.ts, where the issue identifies how the enabled parameter becomes a query filter. Then find or add end-to-end coverage for GET /api/v1/livechat/department?enabled=false. Done means disabled departments are returned, and the response is empty when all departments are enabled.

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

Descrizione

type: bug
Description:

When querying the Omnichannel departments endpoint with GET /api/v1/livechat/department?enabled=false, the enabled=false query parameter is ignored by the backend query builder. As a result, active/enabled departments are returned instead of only disabled departments.

Steps to reproduce:
  1. Create a Livechat department in Omnichannel and make sure it is enabled (enabled: true).
  2. Send an authenticated request:
    GET /api/v1/livechat/department?enabled=false
  3. Inspect the returned departments array and count.
Expected behavior:

The endpoint should only return disabled departments (enabled: false). If all departments in the workspace are enabled, it should return an empty array [] (count: 0):

{
  "departments": [],
  "count": 0,
  "offset": 0,
  "total": 0,
  "success": true
}
Actual behavior:

The enabled=false filter is ignored by the backend query builder. Rocket.Chat returns active departments (enabled: true):

WhatsApp Image 2026-11-11 at 17 17 53
{
  "departments": [
    {
      "_id": "6af442eb499c57876de2b0d4",
      "name": "Enabled Dept 1794392811642",
      "enabled": true
    }
  ],
  "count": 1,
  "offset": 0,
  "total": 1,
  "success": true
}
Server Setup Information:
  • Version of Rocket.Chat Server: 8.9.1 (reproduced on latest develop 8.x)
  • License Type: Community / Enterprise
  • Number of Users: 1
  • Operating System: Linux / Windows
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 24.22.1
  • MongoDB Version: 8.0.34
Client Setup Information
  • Desktop App or Browser Version: REST API / Chrome
  • Operating System: Windows 11
Additional context
Root Cause Analysis:
  1. In apps/meteor/server/api/v1/omnichannel/departments.ts:

    enabled: enabled === 'true',
    

    When enabled query parameter is 'false', it evaluates to false. When enabled is omitted (fetching all departments), undefined === 'true' also evaluates to false.

  2. In apps/meteor/server/api/v1/omnichannel/lib/departments.ts:

    ...(enabled && { enabled: Boolean(enabled) }),
    

    Because enabled is boolean false, JavaScript evaluates false && { enabled: ... } to false. The { enabled: false } filter is therefore completely omitted from the MongoDB query, returning all departments regardless of the requested status.

I have already verified this live on a running instance and prepared a PR with the fix and automated end-to-end test coverage.

Relevant logs:
GET /api/v1/livechat/department?enabled=false
Status: 200 OK
Departments returned: 1 (expected 0)
Department: "Enabled Dept 1794392811642" (enabled: true)
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.