{"record":{"id":"71c2aa0a6509abb6","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-71c2aa","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/getSupportedLanguages.ts","lineNumber":20,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { DDPRateLimiter } from 'meteor/ddp-rate-limiter';\nimport { Meteor } from 'meteor/meteor';\n\nimport { getSupportedLanguages } from '../../lib/autotranslate/functions/getSupportedLanguages';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'autoTranslate.getSupportedLanguages'(targetLanguage: string): ISupportedLanguage[] | undefined;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync 'autoTranslate.getSupportedLanguages'(targetLanguage) {\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'getSupportedLanguages',\n\t\t\t});\n\t\t}\n\n\t\treturn getSupportedLanguages(userId, targetLanguage);\n\t},\n});\n\nDDPRateLimiter.addRule(\n\t{\n\t\ttype: 'method',\n\t\tname: 'autoTranslate.getSupportedLanguages',\n\t\tuserId(/* userId*/) {\n\t\t\treturn true;\n\t\t},\n\t},\n\t5,\n\t60000,","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/getSupportedLanguages.ts#L2-L38","documentation":"Thrown by 'autoTranslate.getSupportedLanguages' when there is no authenticated user. The method resolves the caller's translation provider via getSupportedLanguages(userId, targetLanguage), so a session is required. Note the thrown error's details use method: 'getSupportedLanguages' (without the autoTranslate. prefix) — a metadata mismatch to be aware of when matching on details.method.","triggerScenarios":"Requesting supported translation languages from a logged-out client; the translation settings UI loads before login resolves; session expiry while the language picker fetches options.","commonSituations":"Language pickers rendered pre-login; expired sessions in long-open tabs; consumers matching on the error payload's method field hitting the name mismatch.","solutions":["Ensure a session exists before requesting supported languages","Guard with Meteor.userId() and defer the call until login completes","When inspecting error details, expect method 'getSupportedLanguages' rather than the full method name","Prefer a REST equivalent for new integrations"],"exampleFix":"// before\nconst langs = await Meteor.callAsync('autoTranslate.getSupportedLanguages', targetLanguage);\n\n// after\nif (!Meteor.userId()) {\n  // language list depends on the user's translation provider; wait for login\n  return [];\n}\nconst langs = await Meteor.callAsync('autoTranslate.getSupportedLanguages', targetLanguage);","handlingStrategy":"validation","validationCode":"// client: supported languages depend on the logged-in user's provider\nif (!Meteor.userId()) {\n  // return a safe default instead of calling\n}","typeGuard":"import { Meteor } from 'meteor/meteor';\n\nconst isMeteorError = (err: unknown, code?: string): err is Meteor.Error =>\n  err instanceof Meteor.Error && (code === undefined || err.error === code);","tryCatchPattern":"try {\n  const langs = await Meteor.callAsync('autoTranslate.getSupportedLanguages', targetLanguage);\n} catch (err) {\n  if (isMeteorError(err, 'error-invalid-user')) {\n    // wait for login, then refetch\n  } else {\n    throw err;\n  }\n}","preventionTips":["Defer language-list fetches until the session is established","Do not match on details.method for this error — the payload says 'getSupportedLanguages', not the full method name"],"tags":["meteor","authentication","rocket-chat","autotranslate","error-code-mismatch"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}