Skip to content

Department update not working properly on 3.5.0 #18392

@paulobernardoaf

Description

@paulobernardoaf

Description:

There is a bug present on the current master branch (3.5.0) that occur when trying to update the department. I believe it was introduced here: #17049

  • What I've noticed is that when trying to make that same Update department API request, here the agents list variable is not passed as argument in the Livechat.saveDepartment() function, but this function calls updateDepartmentAgents function and that one requires the agent list variable, making the request always cause an error on Rocket.Chat.
  • Besides that, there's another missing attribute/parameter here. This Livechat.saveDepartmentsAgents() function only receives the upsert attribute on the second parameter, but the remove attribute is marked as mandatory here, making the request always cause an error on Rocket.Chat again.

Steps to reproduce:

  1. Try to update department agents' data with the Rocket.Chat REST API

Expected behavior:

The request return 200 without any errors.

Actual behavior:

The response is 400, returning an error message from Rocket.Chat (logs below) and the department data is not updated.

Server Setup Information:

  • Version of Rocket.Chat Server: 3.5.0
  • Operating System: Pop!_OS 20.04 LTS
  • Deployment Method: meteor npm start
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 12.16.1 - x64
  • MongoDB Version: 4.2.5

Client Setup Information

  • Desktop App or Browser Version: Google Chrome Version 84.0.4147.89 (Official Build) (64-bit)
  • Operating System: Pop!_OS 20.04 LTS

Additional context

Relevant logs:

  • Request response for the first part of the bug:
{
    "statusCode": 400,
    "content": "{\n  \"message\": \"Match error: Expected object, got undefined\",\n  \"path\": \"\",\n  \"sanitizedError\": {\n    \"isClientSafe\": true,\n    \"error\": 400,\n    \"reason\": \"Match failed\",\n    \"message\": \"Match failed [400]\",\n    \"errorType\": \"Meteor.Error\"\n  },\n  \"errorType\": \"Match.Error\",\n  \"success\": false\n}",
    "headers": {
      "x-xss-protection": "1",
      "x-content-type-options": "nosniff",
      "x-frame-options": "sameorigin",
      "x-instance-id": "iCHSy7E7HrpfZxxGZ",
      "cache-control": "no-store",
      "pragma": "no-cache",
      "content-type": "application/json",
      "vary": "Accept-Encoding",
      "date": "Mon, 27 Jul 2020 15:52:44 GMT",
      "connection": "close",
      "transfer-encoding": "chunked"
    },
    "data": {
      "message": "Match error: Expected object, got undefined",
      "path": "",
      "sanitizedError": {
        "isClientSafe": true,
        "error": 400,
        "reason": "Match failed",
        "message": "Match failed [400]",
        "errorType": "Meteor.Error"
      },
      "errorType": "Match.Error",
      "success": false
    }
  }
  • Request response for the second part of the bug:
{
    "statusCode": 400,
    "content": "{\n  \"message\": \"Match error: Missing key 'remove'\",\n  \"path\": \"\",\n  \"sanitizedError\": {\n    \"isClientSafe\": true,\n    \"error\": 400,\n    \"reason\": \"Match failed\",\n    \"message\": \"Match failed [400]\",\n    \"errorType\": \"Meteor.Error\"\n  },\n  \"errorType\": \"Match.Error\",\n  \"success\": false\n}",
    "headers": {
      "x-xss-protection": "1",
      "x-content-type-options": "nosniff",
      "x-frame-options": "sameorigin",
      "x-instance-id": "q3jggGfwWkjWqmKkA",
      "cache-control": "no-store",
      "pragma": "no-cache",
      "content-type": "application/json",
      "vary": "Accept-Encoding",
      "date": "Mon, 27 Jul 2020 15:54:10 GMT",
      "connection": "close",
      "transfer-encoding": "chunked"
    },
    "data": {
      "message": "Match error: Missing key 'remove'",
      "path": "",
      "sanitizedError": {
        "isClientSafe": true,
        "error": 400,
        "reason": "Match failed",
        "message": "Match failed [400]",
        "errorType": "Meteor.Error"
      },
      "errorType": "Match.Error",
      "success": false
    }
  }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions