{"record":{"id":"6c694788465e2e3a","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-6c6947","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/banner_dismiss.ts","lineNumber":20,"sourceCode":"import { Users } from '@rocket.chat/models';\nimport { Meteor } from 'meteor/meteor';\n\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\nimport { notifyOnUserChange } from '../../lib/notifyListener';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'banner/dismiss'({ id }: { id: string }): void;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync 'banner/dismiss'({ id }) {\n\t\tmethodDeprecationLogger.method('banner/dismiss', '9.0.0', '/v1/banners.dismiss');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'banner/dismiss' });\n\t\t}\n\n\t\tawait Users.setBannerReadById(userId, id);\n\n\t\tvoid notifyOnUserChange({\n\t\t\tid: userId,\n\t\t\tclientAction: 'updated',\n\t\t\tdiff: {\n\t\t\t\t[`banners.${id}.read`]: true,\n\t\t\t},\n\t\t});\n\t},\n});\n","sourceCodeStart":2,"sourceCodeEnd":34,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/banner_dismiss.ts#L2-L34","documentation":"The banner/dismiss Meteor method requires an authenticated user; Meteor.userId() returned null. The method is deprecated since 9.0.0 in favor of POST /v1/banners.dismiss, as logged by methodDeprecationLogger on every call.","triggerScenarios":"Calling 'banner/dismiss' on an unauthenticated DDP connection or before the saved login resumes; stale clients on upgraded workspaces still calling the deprecated method.","commonSituations":"Upgrade to Rocket.Chat 9.x where the method is deprecated; custom clients dismissing banners during startup races; scripts calling the method without a session.","solutions":["Migrate to POST /api/v1/banners.dismiss with { bannerId } and auth headers (the DDP method will be removed)","Ensure the user is logged in before calling (check Meteor.userId() client-side)","On this error, re-authenticate once and retry, or fall back to the REST endpoint"],"exampleFix":"// before\nMeteor.call('banner/dismiss', { id });\n\n// after\nawait fetch('/api/v1/banners.dismiss', {\n  method: 'POST',\n  headers: { 'X-Auth-Token': token, 'X-User-Id': uid, 'Content-Type': 'application/json' },\n  body: JSON.stringify({ bannerId: id }),\n});","handlingStrategy":"try-catch","validationCode":"if (!Meteor.userId()) {\n  await ensureLogin();\n}\n// better: migrate off the deprecated method entirely","typeGuard":"const isInvalidUserError = (e: unknown): e is Meteor.Error =>\n  typeof e === 'object' && e !== null && (e as { error?: string }).error === 'error-invalid-user';","tryCatchPattern":"try {\n  Meteor.call('banner/dismiss', { id });\n} catch (e) {\n  if (isInvalidUserError(e)) {\n    await reauthenticate();\n    return dismissBannerViaRest(id); // POST /v1/banners.dismiss\n  }\n  throw e;\n}","preventionTips":["Replace banner/dismiss with POST /v1/banners.dismiss before the 9.x removal","Check Meteor.userId() before any authenticated method call","Watch methodDeprecationLogger warnings during upgrade testing"],"tags":["rocket-chat","meteor","authentication","banners","deprecation"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}