{"record":{"id":"0ca391dd25305c3c","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-0ca391","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/irc/methods/resetIrcConnection.ts","lineNumber":24,"sourceCode":"import { notifyOnSettingChangedById } from '../../../lib/notifyListener';\nimport { settings } from '../../../settings';\nimport { updateAuditedByUser } from '../../../settings/lib/auditedSettingUpdates';\nimport Bridge from '../irc-bridge';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tresetIrcConnection(): { message: string; params: unknown[] };\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync resetIrcConnection() {\n\t\tconst ircEnabled = Boolean(settings.get('IRC_Enabled'));\n\t\tconst uid = Meteor.userId();\n\n\t\tif (!uid) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'resetIrcConnection' });\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(uid, 'edit-privileged-setting'))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'resetIrcConnection' });\n\t\t}\n\n\t\tconst auditSettingOperation = updateAuditedByUser({\n\t\t\t_id: uid,\n\t\t\tusername: (await Meteor.userAsync())!.username!,\n\t\t\tip: this.connection?.clientAddress || '',\n\t\t\tuseragent: this.connection?.httpHeaders['user-agent'] || '',\n\t\t});\n\n\t\tconst updatedLastPingValue = await auditSettingOperation(Settings.updateValueById, 'IRC_Bridge_Last_Ping', new Date(0), {\n\t\t\tupsert: true,\n\t\t});\n\t\tif (updatedLastPingValue.modifiedCount || updatedLastPingValue.upsertedCount) {\n\t\t\tvoid notifyOnSettingChangedById('IRC_Bridge_Last_Ping');","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/bridges/irc/methods/resetIrcConnection.ts#L6-L42","documentation":"Thrown by the resetIrcConnection Meteor method when Meteor.userId() is falsy, i.e. there is no authenticated user on the DDP connection. The method is server-only and requires a logged-in user before it checks IRC_Enabled or the edit-privileged-setting permission.","triggerScenarios":"Client calls Meteor.call('resetIrcConnection') on a connection where the user is not logged in, or the login session expired before the call landed. Also possible from a server-side call that has no user context.","commonSituations":"Long-idled admin tab whose session expired still has the 'Reset IRC' button enabled. A method call fired during logout race. Server-side invocation without binding a user.","solutions":["Ensure the client is authenticated (login completed) before calling resetIrcConnection; re-login on 401/expired-session signals.","Disable the UI control when no user/session is present.","From server code, bind a user context or gate the call behind an authenticated admin path."],"exampleFix":"// before\nMeteor.call('resetIrcConnection') // while logged out\n\n// after\nif (Meteor.userId()) Meteor.call('resetIrcConnection')\nelse reLogin().then(() => Meteor.call('resetIrcConnection'))","handlingStrategy":"validation","validationCode":"const uid = Meteor.userId();\nif (!uid) throw new Meteor.Error('error-invalid-user','login required');\nawait Meteor.call('resetIrcConnection');","typeGuard":"function isAuthenticated() { return typeof Meteor.userId() === 'string'; }","tryCatchPattern":"try { Meteor.call('resetIrcConnection'); }\ncatch (e) {\n  if (e?.error === 'error-invalid-user') { await reLogin(); Meteor.call('resetIrcConnection'); return; }\n  throw e;\n}","preventionTips":["Check Meteor.userId() before calling protected methods.","Re-login on session-expired signals.","Disable admin controls when no session is active."],"tags":["meteor","methods","irc","bridge","authentication","users"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}