[Bug]: Livechat GET /api/v1/livechat/department?enabled=false ignores filter and returns enabled departments
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- mongodb, node.js, typescript
Research direction
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.
Written by the indexing model from the issue text.
Description
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:
- Create a Livechat department in Omnichannel and make sure it is enabled (
enabled: true). - Send an authenticated request:
GET /api/v1/livechat/department?enabled=false - 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):
{
"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
develop8.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:
-
In
apps/meteor/server/api/v1/omnichannel/departments.ts:enabled: enabled === 'true',When
enabledquery parameter is'false', it evaluates tofalse. Whenenabledis omitted (fetching all departments),undefined === 'true'also evaluates tofalse. -
In
apps/meteor/server/api/v1/omnichannel/lib/departments.ts:...(enabled && { enabled: Boolean(enabled) }),Because
enabledis booleanfalse, JavaScript evaluatesfalse && { enabled: ... }tofalse. 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)
- Dominant language
- TypeScript
- Stars
- 46.5k
- Forks
- 14.1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 381
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RocketChat/Rocket.Chat
-
Mark the empty state busy while a new search loads, like the table */}Possibly taken @aditya25bcy10173-a11y claimed this 2 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RocketChat/Rocket.Chat#43699 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Timestamp with a time but no timezone shows as 1 January 1970Possibly taken @Sarthak-agrawal-tech claimed this 4 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43637 · 6 comments ·
Maintainers usually reply within 1 day
-
Move this mapping from useQuery's old `select` into a usePaginatedQuery `combine`Possibly taken @aditya25bcy10173-a11y claimed this 3 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43609 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
evaluate switching to the other tab when the selected tab's permission is revoked mid-sessionPossibly taken @schizophrenicmaniac claimed this 4 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RocketChat/Rocket.Chat#43579 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Docs say packages can be installed with `npm` but use unsupported `patch:` URLPossibly taken A pull request linked to this issue is open or already merged. Opentype: bug
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43554 · 4 comments ·
Maintainers usually reply within 1 day
All issues in RocketChat/Rocket.Chat
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
open-webui/tether#52 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
voidzero-dev/void#835 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AykutSarac/jsoncrack.com#616 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
melgarafael/DeskcommCRM#4679 ·
Maintainers usually reply within 1 day