{"record":{"id":"7e18bf55445329f6","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-7e18bf","errorCode":null,"errorMessage":"invalid user","messagePattern":"invalid user","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/meteor/server/modules/core-apps/banner.module.ts","lineNumber":16,"sourceCode":"import { Banner } from '@rocket.chat/core-services';\nimport type { IUiKitCoreApp, UiKitCoreAppViewClosedPayload } from '@rocket.chat/core-services';\nimport type * as UiKit from '@rocket.chat/ui-kit';\n\nexport class BannerModule implements IUiKitCoreApp {\n\tappId = 'banner-core';\n\n\t// when banner view is closed we need to dismiss that banner for that user\n\tasync viewClosed(payload: UiKitCoreAppViewClosedPayload): Promise<UiKit.ServerInteraction> {\n\t\tconst {\n\t\t\tpayload: { view: { viewId: bannerId } = {} },\n\t\t\tuser: { _id: userId } = {},\n\t\t} = payload;\n\n\t\tif (!userId) {\n\t\t\tthrow new Error('invalid user');\n\t\t}\n\n\t\tif (!bannerId) {\n\t\t\tthrow new Error('invalid banner');\n\t\t}\n\n\t\tif (!payload.triggerId) {\n\t\t\tthrow new Error('invalid triggerId');\n\t\t}\n\n\t\tawait Banner.dismiss(userId, bannerId);\n\n\t\treturn {\n\t\t\ttype: 'banner.close',\n\t\t\ttriggerId: payload.triggerId,\n\t\t\tappId: payload.appId,\n\t\t\tviewId: bannerId,\n\t\t};","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/modules/core-apps/banner.module.ts#L1-L34","documentation":"`BannerModule` is the UiKit core app `banner-core` that processes close events for in-app banners. `viewClosed()` destructures `payload.user._id`; when it is missing there is no user to dismiss the banner for, so the module throws a plain `Error('invalid user')` before ever reaching `Banner.dismiss(userId, bannerId)`. This is a payload-shape guard, not an authentication check.","triggerScenarios":"Dispatching a `viewClosed` interaction to the `banner-core` app where `payload.user` or `payload.user._id` is undefined — e.g. a programmatically built payload, a test double that omits the user, or a client still rendering a banner after logout.","commonSituations":"Custom server code closing banners by emitting UiKit core events instead of calling `Banner.dismiss`; payload mocks in unit tests; DDP reconnect after logout while a banner surface is still open.","solutions":["Include `user: { _id: userId }` in the `viewClosed` payload.","For programmatic dismissal, bypass the module and call `Banner.dismiss(userId, bannerId)` from `@rocket.chat/core-services` directly.","Make sure the code path that generates the `triggerId` also attaches the acting user to the interaction payload."],"exampleFix":"// before\nawait bannerModule.viewClosed({\n  appId: 'banner-core',\n  payload: { view: { viewId: bannerId }, triggerId },\n} as any);\n\n// after\nawait bannerModule.viewClosed({\n  appId: 'banner-core',\n  user: { _id: userId },\n  payload: { view: { viewId: bannerId }, triggerId },\n} as any);","handlingStrategy":"validation","validationCode":"const canDismiss = (payload: UiKitCoreAppViewClosedPayload): boolean =>\n  Boolean(payload.user?._id && payload.payload?.view?.viewId && payload.triggerId);\n\nif (canDismiss(payload)) {\n  await bannerModule.viewClosed(payload);\n}","typeGuard":"function isCompleteBannerClosePayload(\n  payload: UiKitCoreAppViewClosedPayload,\n): payload is UiKitCoreAppViewClosedPayload & { user: { _id: string }; payload: { view: { viewId: string } }; triggerId: string } {\n  return Boolean(payload.user?._id && payload.payload?.view?.viewId && payload.triggerId);\n}","tryCatchPattern":"try {\n  await bannerModule.viewClosed(payload);\n} catch (error) {\n  if (error instanceof Error && error.message === 'invalid user') {\n    return; // no user context: nothing to dismiss\n  }\n  throw error;\n}","preventionTips":["Always attach the acting user when building UiKit core interactions","Call Banner.dismiss directly for programmatic banner dismissal","Type payloads with UiKitCoreAppViewClosedPayload instead of casting to any"],"tags":["uikit","banner","payload-validation","core-apps"],"backgroundTag":"uikit-interaction-payload-invalid","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}