{"record":{"id":"41b87c0818466495","repo":"RocketChat/Rocket.Chat","slug":"invalid-triggerid-41b87c","errorCode":null,"errorMessage":"invalid triggerId","messagePattern":"invalid triggerId","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts","lineNumber":67,"sourceCode":"\t\treturn this.handlePayload(payload);\n\t}\n\n\tasync viewClosed(payload: UiKitCoreAppViewClosedPayload): Promise<UiKit.ServerInteraction | undefined> {\n\t\tconst {\n\t\t\tpayload: { view: { viewId, id } = {} },\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 (!id && !viewId) {\n\t\t\tthrow new Error('invalid view');\n\t\t}\n\n\t\tif (!payload.triggerId) {\n\t\t\tthrow new Error('invalid triggerId');\n\t\t}\n\n\t\t// For backwards compatibility: we prefer to use viewId, but some legacy banners\n\t\t// may only have id. We fetch all matching banners and prioritize viewId match.\n\t\tconst bannerIds = [viewId, id].filter((bannerId) => isTruthy(bannerId));\n\t\tconst banners = await Banners.findByIds(bannerIds).toArray();\n\t\tconst announcement = banners.find((b) => b._id === viewId) || banners.find((b) => b._id === id);\n\t\tif (!announcement) {\n\t\t\tthrow new Error('Banner not found');\n\t\t}\n\n\t\tawait Banner.dismiss(userId, announcement._id);\n\n\t\tconst type = announcement.surface === 'banner' ? 'banner.close' : 'modal.close';\n\n\t\t// for viewClosed we just need to let Cloud know that the banner was closed, no need to wait for the response\n\n\t\tvoid this.handlePayload(payload);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts#L49-L85","documentation":"`CloudAnnouncementsModule.viewClosed` throws `Error('invalid triggerId')` when `payload.triggerId` is falsy. The triggerId is needed both to acknowledge the close to Cloud (the interaction is forwarded via `handlePayload`) and to address the `banner.close`/`modal.close` response back to the client surface, so the guard fires before dismissal.","triggerScenarios":"Closing a cloud announcement banner via a viewClosed interaction that carries no `triggerId` — e.g. manually constructed payloads, replayed log entries, or an outdated client that does not propagate the trigger.","commonSituations":"Custom scripts mimicking the banner close flow; test doubles omitting trigger metadata; intermediate layers dropping fields.","solutions":["Forward the `triggerId` from the surface that displayed the announcement in the viewClosed payload.","For dismissal without a UI surface, call `Banner.dismiss(userId, bannerId)` directly — no triggerId needed."],"exampleFix":"// before\nawait module.viewClosed({ appId: 'cloud-announcements-core', user: { _id: userId }, payload: { view: { viewId } } } as any);\n\n// after\nawait module.viewClosed({ appId: 'cloud-announcements-core', user: { _id: userId }, payload: { view: { viewId } }, triggerId } as any);","handlingStrategy":"validation","validationCode":"if (!payload.triggerId) {\n  throw new Error('triggerId is required to close a cloud announcement');\n}\nawait announcementsModule.viewClosed(payload);","typeGuard":"const hasTrigger = (\n  payload: UiKitCoreAppViewClosedPayload,\n): payload is UiKitCoreAppViewClosedPayload & { triggerId: string } =>\n  typeof payload.triggerId === 'string' && payload.triggerId.length > 0;","tryCatchPattern":"try {\n  await announcementsModule.viewClosed(payload);\n} catch (error) {\n  if (error instanceof Error && error.message === 'invalid triggerId') {\n    // fall back to Banner.dismiss(userId, bannerId) without notifying the surface\n  }\n}","preventionTips":["Propagate triggerId from the surface that displayed the announcement","Call Banner.dismiss directly when no client response is needed"],"tags":["uikit","cloud","announcements","triggerid","payload-validation"],"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"}