Rocket.chat: Issue while changing profile username

Created on 8 Aug 2016  ยท  12Comments  ยท  Source: RocketChat/Rocket.Chat

Your Rocket.Chat version: (make sure you are running the latest)
0.36
Whenever I got to change my username in RC I get the following error but the old messages change names.

Exception while invoking method 'saveUserProfile' MongoError: The positional operator did not find the match needed from the query. Unexpanded update: mentions.$.username     at Object.Future.wait (/app/bundle/programs/server/node_modules/fibers/future.js:398:15)     at [object Object].<anonymous> (packages/meteor/helpers.js:119:1)     at [object Object].MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:736:1)     at Object.CollectionHooks.defineAdvice.self (packages/matb33_collection-hooks/update.js:80:1)     at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks/collection-hooks.js:117:1)     at [object Object].Mongo.Collection.(anonymous function) (packages/mongo/collection.js:590:1)     at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:300:1)     at _Class.update (server/models/_Base.js:78:29)     at _Class.RocketChat.models.Messages._Class.updateUsernameAndMessageOfMentionByIdAndOldUsername (packages/rocketchat_lib/server/models/Messages.coffee:231:11)     at packages/rocketchat_lib/server/functions/setUsername.coffee:40:31     - - - - -     at Object.toError (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/utils.js:114:11)     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/collection/core.js:577:27     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/db.js:1197:7     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/db.js:1905:9     at Server.Base._callHandler (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:488:18     at [object Object].MongoReply.parseBody (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)     at [object Object].<anonymous> (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:446:20)     at [object Object].emit (events.js:95:17)     at [object Object].<anonymous> (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13) 
user settings bug

Most helpful comment

Fixed via https://github.com/RocketChat/Rocket.Chat/pull/4122 in develop right now, will be available in version 0.39.0

All 12 comments

We are also experiencing this issue using LDAP with 0.36

I20160808-12:48:17.464(0) Meteor โž” method ldap_sync_users -> userId: rSRSZnhs7syfkwabv , arguments:  {} 
I20160808-12:48:17.467(0) LDAP โž” Connection.info Init setup 
I20160808-12:48:17.468(0) LDAP โž” Connection.info Connecting ldaps://ldap-ds.<Redacted>.kg:636 
I20160808-12:48:17.476(0) LDAP โž” Connection.debug connectionOptions { url: 'ldaps://ldap-ds.<Redacted>.kg:636',   timeout: 5000,   connectTimeout: 10000,   idleTimeout: 10000,   reconnect: false,   tlsOptions: { rejectUnauthorized: true } } 
I20160808-12:48:17.529(0) LDAP โž” Connection.info LDAP connected 
I20160808-12:48:17.535(0) LDAP โž” Bind.info Binding admin user cn=<Redacted>,ou=machines,dc=<Redacted>,dc=kg 
I20160808-12:48:17.539(0) LDAP โž” Search.info Searching by id 3132323930 
I20160808-12:48:17.540(0) LDAP โž” Search.debug search filter (uidNumber=12290) 
I20160808-12:48:17.540(0) LDAP โž” Search.debug domain_base dc=<Redacted>,dc=kg 
I20160808-12:48:17.552(0) LDAP โž” Search.info Search result count 1 
I20160808-12:48:17.553(0) LDAP โž” Search.debug Search result [   {     "messageID": 2,     "protocolOp": "SearchEntry",     "objectName": "cn=<User First Name>.<User Last Name>,ou=users,ou=<Redacted>,dc=<Redacted>,dc=kg",     "attributes": [       {         "type": "givenName",         "vals": [           "<User First Name>"         ]       },       {         "type": "sn",         "vals": [           "<User Last Name>"         ]       },       {         "type": "cn",         "vals": [           "<User First Name>.<User Last Name>"         ]       },       {         "type": "homeDirectory",         "vals": [           "/home/<User First Name>.<User Last Name>"         ]       },       {         "type": "loginShell",         "vals": [           "/bin/bash"         ]       },       {         "type": "objectClass",         "vals": [           "inetOrgPerson",           "posixAccount",           "top",           "person"         ]       },       {         "type": "uid",         "vals": [           "<User First Name>.<User Last Name>"         ]       },       {         "type": "mail",         "vals": [           "<User First Name>.<User Last Name>@project-<Redacted>.com"         ]       },       {         "type": "gidNumber",         "vals": [           "12503"         ]       },       {         "type": "uidNumber",         "vals": [           "12290"         ]       },       {         "type": "displayName",         "vals": [           "<User First Name> <User Last Name> [OPS]"         ]       }     ],     "controls": []   } ] 
I20160808-12:48:17.554(0) LDAPSync โž” info Syncing user data 
I20160808-12:48:17.555(0) LDAPSync โž” debug user { _id: 'hEbqwxR62yxCfvBTD',   createdAt: Fri Jun 03 2016 12:17:00 GMT+0000 (UTC),   services:     { password: { bcrypt: '<Redacted>' },      ldap: { idAttribute: 'uidNumber', id: '3132323930' },      resume: { loginTokens: [Object] } },   username: '<User First Name>.<User Last Name>.ops',   emails: [ { address: '<User First Name>.<User Last Name>@project-<Redacted>.com', verified: true } ],   type: 'user',   status: 'online',   active: true,   roles: [ 'user', 'admin' ],   ldap: true,   lastLogin: Mon Aug 08 2016 11:52:32 GMT+0000 (UTC),   statusConnection: 'online',   utcOffset: 2,   statusDefault: 'online',   name: '<User First Name> <User Last Name> [OPS]',   avatarOrigin: 'upload',   settings: { preferences: { viewMode: 0 } },   _updatedAt: Mon Aug 08 2016 11:52:32 GMT+0000 (UTC) } 
I20160808-12:48:17.561(0) LDAPSync โž” debug ldapUser { messageID: 2,   protocolOp: 100,   controls: [],   log:     { domain: null,      _events: {},      _maxListeners: 10,      _isSimpleChild: true,      _level: 30,      streams: [ [Object] ],      serializers:        { req: [Function: req],         res: [Function: res],         err: [Function: err] },      src: false,      fields:        { name: 'ldapjs',         component: 'client',         hostname: 'rocket-chat-v0.36.0-bmsjg',         pid: 1,         clazz: 'Client' } },   id: [Getter],   dn: [Getter],   type: [Getter],   json: [Getter],   objectName: 'cn=<User First Name>.<User Last Name>,ou=users,ou=<Redacted>,dc=<Redacted>,dc=kg',   attributes:     [ { type: 'givenName',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'sn',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'cn',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'homeDirectory',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'loginShell',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'objectClass',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'uid',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'mail',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'gidNumber',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'uidNumber',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] },      { type: 'displayName',        _vals: [Object],        vals: [Getter/Setter],        buffers: [Getter],        json: [Getter] } ],   object: [Getter],   raw: [Getter],   _dn: [Getter],   connection:     { _readableState:        { highWaterMark: 16384,         buffer: [],         length: 0,         pipes: null,         pipesCount: 0,         flowing: false,         ended: false,         endEmitted: false,         reading: false,         calledRead: true,         sync: false,         needReadable: true,         emittedReadable: false,         readableListening: false,         objectMode: false,         defaultEncoding: 'utf8',         ranOut: false,         awaitDrain: 0,         readingMore: true,         decoder: null,         encoding: null },      readable: true,      domain: null,      _events:        { finish: [Object],         sslOutEnd: [Function],         data: [Function: onData],         readable: [Function],         end: [Function: onEnd],         error: [Function: onSocketError],         timeout: [Function: onTimeout] },      _maxListeners: 10,      _writableState:        { highWaterMark: 16384,         objectMode: false,         needDrain: false,         ending: false,         ended: false,         finished: false,         decodeStrings: true,         defaultEncoding: 'utf8',         length: 0,         writing: false,         sync: false,         bufferProcessing: false,         onwrite: [Function],         writecb: null,         writelen: 0,         buffer: [],         errorEmitted: false },      writable: true,      allowHalfOpen: true,      pair:        { domain: null,         _events: [Object],         _maxListeners: 10,         server: undefined,         _secureEstablished: true,         _isServer: false,         _encWriteState: true,         _clearWriteState: true,         _doneFlag: false,         _destroying: false,         credentials: [Object],         _rejectUnauthorized: true,         _requestCert: true,         ssl: {},         servername: false,         cleartext: [Circular],         encrypted: [Object],         fd: undefined,         npnProtocol: undefined },      _pending: null,      _pendingEncoding: '',      _pendingCallback: null,      _doneFlag: false,      _retryAfterPartial: false,      _halfRead: false,      _sslOutCb: null,      _resumingSession: false,      _reading: true,      _destroyed: false,      _ended: false,      _finished: false,      _opposite:        { _readableState: [Object],         readable: true,         domain: null,         _events: [Object],         _maxListeners: 10,         _writableState: [Object],         writable: true,         allowHalfOpen: true,         pair: [Object],         _pending: null,         _pendingEncoding: '',         _pendingCallback: null,         _doneFlag: false,         _retryAfterPartial: false,         _halfRead: false,         _sslOutCb: null,         _resumingSession: false,         _reading: true,         _destroyed: false,         _ended: false,         _finished: false,         _opposite: [Circular],         _buffer: [Object] },      _buffer:        { isFull: false,         pool: <Buffer 16 03 01 01 38 01 00 01 34 03 03 07 11 2d 44 5a aa b6 f7 68 7e 4e ee 81 70 54 71 2b 0a d0 bc db 49 fb 8e ef 7b 58 b2 57 6a d3 cc 00 00 84 c0 30 c0 2c c0 ...>,         offset: 1715978,         remaining: 8769782 },      _handle: { readStop: [Function], readStart: [Function] },      socket:        { _connecting: false,         _handle: [Object],         _readableState: [Object],         readable: true,         domain: null,         _events: [Object],         _maxListeners: 10,         _writableState: [Object],         writable: true,         allowHalfOpen: false,         onend: null,         destroyed: false,         bytesRead: 4218,         _bytesDispatched: 728,         _pendingData: null,         _pendingEncoding: '',         read: [Function],         _consuming: true },      encrypted:        { _readableState: [Object],         readable: true,         domain: null,         _events: [Object],         _maxListeners: 10,         _writableState: [Object],         writable: true,         allowHalfOpen: true,         pair: [Object],         _pending: null,         _pendingEncoding: '',         _pendingCallback: null,         _doneFlag: false,         _retryAfterPartial: false,         _halfRead: false,         _sslOutCb: null,         _resumingSession: false,         _reading: true,         _destroyed: false,         _ended: false,         _finished: false,         _opposite: [Circular],         _buffer: [Object] },      authorized: true,      _controlReleased: true,      pipe: [Function],      addListener: [Function: addListener],      on: [Function: addListener],      pause: [Function],      resume: [Function],      npnProtocol: undefined } } 
I20160808-12:48:17.563(0) LDAPSync โž” info Syncing user username <User First Name>.<User Last Name>.ops -> <User First Name>.<User Last Name> 
I20160808-12:48:18.402(0) sync.js:179 LDAPSync โž” error { [MongoError: The positional operator did not find the match needed from the query. Unexpanded update: mentions.$.username] stack: [Getter] } 
I20160808-12:48:18.404(0) Exception while invoking method 'ldap_sync_users' MongoError: The positional operator did not find the match needed from the query. Unexpanded update: mentions.$.username     at Object.Future.wait (/app/bundle/programs/server/node_modules/fibers/future.js:398:15)     at [object Object].<anonymous> (packages/meteor/helpers.js:119:1)     at [object Object].MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:736:1)     at Object.CollectionHooks.defineAdvice.self (packages/matb33_collection-hooks/update.js:80:1)     at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks/collection-hooks.js:117:1)     at [object Object].Mongo.Collection.(anonymous function) (packages/mongo/collection.js:590:1)     at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:300:1)     at _Class.update (server/models/_Base.js:78:29)     at _Class.RocketChat.models.Messages._Class.updateUsernameAndMessageOfMentionByIdAndOldUsername (packages/rocketchat_lib/server/models/Messages.coffee:231:11)     at packages/rocketchat_lib/server/functions/setUsername.coffee:40:31     - - - - -     at Object.toError (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/utils.js:114:11)     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/collection/core.js:577:27     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/db.js:1197:7     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/db.js:1905:9     at Server.Base._callHandler (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)     at /app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:488:18     at [object Object].MongoReply.parseBody (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)     at [object Object].<anonymous> (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:446:20)     at [object Object].emit (events.js:95:17)     at [object Object].<anonymous> (/app/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13) 

I am having the same issue with the same build. Just want to follow this thread for any updates.

Same here:
Exception while invoking method 'saveUserProfile' MongoError: The positional operator did not find the match needed from the query. Unexpanded update: mentions.$.username ...

+1
v0.37.0

+1
0.37.1

same here +1
0.37.1

@RocketChat/core I experienced this the other day as well. It will get through the process of changing it but then the error happens and now you've got messages with the new username yet when you send messages you've still got your old username.

I'm currently in the process of migrating all self-registered users to LDAP in our Rocket.Chat instance but therefore a bunch of users needs to be renamed so this issue currently blocks the user migration :(

0.38.0
+1

Fixed via https://github.com/RocketChat/Rocket.Chat/pull/4122 in develop right now, will be available in version 0.39.0

For me it's also present in version 0.64.2 for all users.

Here too. Cannot change usernames from Members as an Admin. Latest version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zeigerpuppy picture zeigerpuppy  ยท  3Comments

royalaid picture royalaid  ยท  3Comments

antn89 picture antn89  ยท  3Comments

tanc picture tanc  ยท  3Comments

engelgabriel picture engelgabriel  ยท  3Comments