{"record":{"id":"9a9b4337078a3204","repo":"RocketChat/Rocket.Chat","slug":"error-action-not-allowed-9a9b43","errorCode":"error-action-not-allowed","errorMessage":"Login neccessary","messagePattern":"Login neccessary","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts","lineNumber":16,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Meteor } from 'meteor/meteor';\n\nimport { TranslationProviderRegistry } from '../../lib/autotranslate/autotranslate';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'autoTranslate.getProviderUiMetadata'(): Record<string, { name: string; displayName: string }>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\t'autoTranslate.getProviderUiMetadata'() {\n\t\tif (!Meteor.userId()) {\n\t\t\tthrow new Meteor.Error('error-action-not-allowed', 'Login neccessary', {\n\t\t\t\tmethod: 'autoTranslate.getProviderUiMetadata',\n\t\t\t});\n\t\t}\n\n\t\treturn Object.fromEntries(\n\t\t\tTranslationProviderRegistry.getProviders().map((provider) => {\n\t\t\t\tconst { name, displayName } = provider._getProviderMetadata();\n\t\t\t\treturn [name, { name, displayName }];\n\t\t\t}),\n\t\t);\n\t},\n});\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts#L1-L29","documentation":"Thrown by 'autoTranslate.getProviderUiMetadata' when there is no authenticated user. Unlike its sibling methods it uses the code 'error-action-not-allowed' with the message 'Login neccessary' (typo present in source) instead of 'error-invalid-user' — code matching must target 'error-action-not-allowed'. It guards metadata (name/displayName) about registered auto-translate providers such as DeepL.","triggerScenarios":"Calling autoTranslate.getProviderUiMetadata anonymously; the auto-translate settings panel loads before the login state resolves; session expired while the admin translation settings were open.","commonSituations":"Settings screens fetched with a stale token; components mounting before user data is ready; translation provider metadata used in pre-login UI by mistake.","solutions":["Ensure the user is logged in before requesting provider metadata","Gate the call with Meteor.userId() and defer it until the session is ready","When catching, match error.error === 'error-action-not-allowed' — not 'error-invalid-user'"],"exampleFix":"// before\nconst providers = await Meteor.callAsync('autoTranslate.getProviderUiMetadata');\n\n// after\nif (!Meteor.userId()) {\n  // provider metadata requires a session; skip until logged in\n  return {};\n}\nconst providers = await Meteor.callAsync('autoTranslate.getProviderUiMetadata');","handlingStrategy":"validation","validationCode":"// client: provider metadata requires a session\nif (!Meteor.userId()) {\n  // skip the metadata fetch until logged in\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  await Meteor.callAsync('autoTranslate.getProviderUiMetadata');\n} catch (err) {\n  // note: this method throws 'error-action-not-allowed', not 'error-invalid-user'\n  if (isMeteorError(err, 'error-action-not-allowed')) {\n    // re-authenticate, then refetch provider metadata\n  } else {\n    throw err;\n  }\n}","preventionTips":["Match on 'error-action-not-allowed' for this method — its auth error code differs from sibling methods","Defer settings-panel fetches until the user session is ready"],"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"}