RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.4k stars 10.51k forks source link

PlanExecutor error, cant open users in admin panel/Users get deactivated when they try to login #31203

Open Jumpy98 opened 10 months ago

Jumpy98 commented 10 months ago

Description:

Hello, Since last week certain users cannot login to RocketChat on Browser, even if they put in the correct data. Their account gets deactivated, "active": false is set if they try to log in. Followed by the "ask a administrator to activate the account manually". When trying to open the User List in the admin panel , a "PlanExecutor error" gets thrown (full log at the bottom). It is still possible to query the users list for certain strings without an error /v1/users.list?query={ "name": { "$regex": "P" } }. Other queries for specific strings still throw the PlanExecutor error (for example /v1/users.list?query={ "name": { "$regex": "A" } }).

What could cause these problems?

Expected behavior:

  1. Go to admin panel
  2. Click on 'Users'
  3. Users should be listed

Actual behavior:

  1. Go to admin panel
  2. Click on 'Users'
  3. PlanExecutor error

Server Setup Information:

Version of Rocket.Chat Server: 6.5
Operating System: ubuntu 22.04
Deployment Method: snap
Number of Running Instances: 1
DB Replicaset Oplog:
NodeJS Version: 14.21.2
MongoDB Version: 5.0.15
Proxy: apache
Firewalls involved:

Client Setup Information

Relevant logs:

"err":{"type":"MongoServerError","message":"PlanExecutor error during aggregation :: caused by :: can't convert from BSON type array to String","stack":"MongoServerError: PlanExecutor error during aggregation :: caused by :: can't convert from BSON type array to String<br> at Connection.onMessage (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:231:30)<br> at MessageStream.<anonymous> (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:61:60)<br> at MessageStream.emit (events.js:400:28)<br> at MessageStream.emit (domain.js:475:12)<br> at processIncomingData (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:125:16)<br> at MessageStream._write (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:33:9)<br> at writeOrBuffer (internal/streams/writable.js:358:12)<br> at MessageStream.Writable.write (internal/streams/writable.js:303:10)<br> at Socket.ondata (internal/streams/readable.js:731:22)<br> at Socket.emit (events.js:400:28)<br> at Socket.emit (domain.js:475:12)<br> at addChunk (internal/streams/readable.js:293:12)<br> at readableAddChunk (internal/streams/readable.js:267:9)<br> at Socket.Readable.push (internal/streams/readable.js:206:10)<br> at TCP.onStreamRead (internal/stream_base_commons.js:188:23)<br> at TCP.callbackTrampoline (internal/async_hooks.js:130:17)<br> => awaited here:<br> at Function.Promise.await (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at app/api/server/v1/users.ts:511:16<br> at /snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40<br> => awaited here:<br> at Function.Promise.await (/snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at packages/meteor.js:367:22<br> at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1389:31)<br> at app/api/server/api.ts:635:39<br> at /snap/rocketchat-server/1597/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40","ok":0,"code":16007,"codeName":"Location16007","$clusterTime":{"clusterTime":{"$timestamp":"7311312120627331073"},"operationTime":{"$timestamp":"7311312120627331073"}},"status":400,"responseTime":16,"msg":"PlanExecutor error during aggregation :: caused by :: can't convert from BSON type array to String"}

Airbornharsh commented 9 months ago

It is Working. Can you attack some secreenshots

Screenshot from 2024-01-08 09-38-24

Jumpy98 commented 9 months ago

It is not working, screenshot shows no more info than the error message planexecutor_error_rc

fangebee commented 5 months ago

@Jumpy98 I encountered the same issue and found out that some "name" attributes where corrupted in mongodb: array instead of a string. I guess it came during the last upgrade's migrations, I don't know.

In my case, I could fix this directly in mongodb.

  1. find the bad records:
    
    > db.users.find({name: {$type: "array"}}, {_id:1,name:1,username:1}).sort({createdAt:-1}).limit(20);
    [ { _id: 'hCZWxxxxxx', username: 'john.doe', name: [] } ]
2. fix them one by one by setting a valid name:

db.users.updateOne({_id: "hCZWxxxxxx"}, {$set: {name: "something_non_empty"}})