{"record":{"id":"f814c3e2006dedca","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-f814c3","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/saveSettings.ts","lineNumber":19,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Meteor } from 'meteor/meteor';\n\nimport { saveAutoTranslateSettings } from '../../lib/autotranslate/functions/saveSettings';\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'autoTranslate.saveSettings'(rid: string, field: string, value: string, options: { defaultLanguage: string }): boolean;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync 'autoTranslate.saveSettings'(rid, field, value, options) {\n\t\tmethodDeprecationLogger.method('autoTranslate.saveSettings', '9.0.0', '/v1/autotranslate.saveSettings');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'saveAutoTranslateSettings',\n\t\t\t});\n\t\t}\n\n\t\treturn saveAutoTranslateSettings(userId, rid, field, value, options);\n\t},\n});\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/saveSettings.ts#L1-L27","documentation":"`autoTranslate.saveSettings` throws `error-invalid-user` when `Meteor.userId()` is null. Auto-translate settings are stored per user, so a session is mandatory. The method is deprecated since 9.0.0 in favor of `/v1/autotranslate.saveSettings`.","triggerScenarios":"Calling `Meteor.call('autoTranslate.saveSettings', rid, field, value, options)` while logged out or with an expired session.","commonSituations":"Settings dialog left open while the session dropped; saving preferences before login finished on a slow client.","solutions":["Require an authenticated session before saving (check `Meteor.userId()`)","Re-login and retry the save when `error-invalid-user` comes back","Migrate to `POST /v1/autotranslate.saveSettings`"],"exampleFix":"// before\nMeteor.call('autoTranslate.saveSettings', rid, field, value, options);\n// after\nif (!Meteor.userId()) {\n  return promptLogin();\n}\nMeteor.call('autoTranslate.saveSettings', rid, field, value, options);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  return handleSessionExpired(); // re-login, then retry the save\n}\nMeteor.call('autoTranslate.saveSettings', rid, field, value, options);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('autoTranslate.saveSettings', rid, field, value, options);\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-invalid-user') {\n    // session expired mid-form: re-authenticate and retry the save once\n  }\n}","preventionTips":["Require a session before opening the auto-translate settings form","Re-verify Meteor.userId() at save time, not just at form-open time","Migrate to POST /v1/autotranslate.saveSettings"],"tags":["autotranslate","authentication","deprecated","meteor-method"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}