{"record":{"id":"a748c7558f6854e1","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-id-a748c7","errorCode":null,"errorMessage":"Invalid user id","messagePattern":"Invalid user id","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/users.ts","lineNumber":170,"sourceCode":"\t\t\t);\n\t\t}\n\n\t\tif (!Object.keys(updateFields).length) {\n\t\t\treturn true;\n\t\t}\n\n\t\tawait Users.updateOne({ _id: user.id }, { $set: updateFields as any });\n\n\t\tvoid notifyOnUserChange({ clientAction: 'updated', id: user.id, diff: updateFields });\n\n\t\treturn true;\n\t}\n\n\tprotected async deactivate(userId: IUser['id'], confirmRelinquish: boolean, appId: string): Promise<boolean> {\n\t\tthis.orch.debugLog(`The App ${appId} is deactivating a user.`);\n\n\t\tif (!userId) {\n\t\t\tthrow new Error('Invalid user id');\n\t\t}\n\n\t\t// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.\n\t\tconst convertedUser: IUser | undefined = await this.orch.getConverters()?.get('users').convertById(userId);\n\t\tconst { id: uid } = convertedUser as IUser;\n\n\t\tawait setUserActiveStatus(uid, false, confirmRelinquish);\n\n\t\treturn true;\n\t}\n\n\tprotected async setActiveState(\n\t\tuserId: IUser['id'],\n\t\tstate: Pick<IUser, 'statusDefault' | 'statusSource' | 'statusText' | 'statusExpiresAt' | 'statusId'>,\n\t\tappId: string,\n\t): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is setting active state for user ${userId}`);\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/users.ts#L152-L188","documentation":"Thrown by the users bridge deactivate method when userId is falsy. Deactivation calls convertById and setUserActiveStatus with the id, so an empty id is rejected before any database lookup to avoid deactivating the wrong (or no) user.","triggerScenarios":"App calls deactivate with an empty string, null, or undefined userId — usually because a user reference was not resolved upstream.","commonSituations":"App acts on a deletion/removal event whose user id field was empty; refactor left a placeholder; chained call forwarded an undefined value.","solutions":["Validate that userId is a non-empty string before calling deactivate.","Resolve the user id from a trusted source and skip the call when it is missing.","Guard the event handler boundary against empty payloads."],"exampleFix":"// before\nawait users.deactivate(maybeUserId, true);\n\n// after\nif (!maybeUserId) {\n  return;\n}\nawait users.deactivate(maybeUserId, true);","handlingStrategy":"validation","validationCode":"if (!userId) {\n  throw new Error('Cannot deactivate: userId is required');\n}","typeGuard":"function isValidUserId(id: unknown): id is string {\n  return typeof id === 'string' && id.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Treat userId as a required precondition at the handler boundary.","Resolve userId from a trusted source and skip when missing.","Guard against empty event payloads before deactivating."],"tags":["apps-engine","users","validation","deactivate","argument-error"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}