{"record":{"id":"7ac7b8fc0707b073","repo":"RocketChat/Rocket.Chat","slug":"invalid-view-7ac7b8","errorCode":null,"errorMessage":"invalid view","messagePattern":"invalid view","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/meteor/server/modules/core-apps/cloudSubscriptionCommunication.module.ts","lineNumber":20,"sourceCode":"import type * as UiKit from '@rocket.chat/ui-kit';\n\nimport { CloudAnnouncementsModule } from './cloudAnnouncements.module';\n\nexport class CloudSubscriptionCommunication extends CloudAnnouncementsModule {\n\toverride appId = 'cloud-communication-core';\n\n\toverride async viewClosed(payload: UiKitCoreAppViewClosedPayload): Promise<UiKit.ServerInteraction> {\n\t\tconst {\n\t\t\tpayload: { view: { viewId } = {} },\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 (!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 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);\n\n\t\treturn {\n\t\t\ttype: 'modal.close',\n\t\t\ttriggerId: payload.triggerId,\n\t\t\tappId: payload.appId,\n\t\t};\n\t}\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/modules/core-apps/cloudSubscriptionCommunication.module.ts#L2-L38","documentation":"`CloudSubscriptionCommunication.viewClosed` throws `Error('invalid view')` when `payload.payload.view.viewId` is missing. Unlike the parent `CloudAnnouncementsModule`, this override has no legacy `id` fallback — it strictly requires `viewId` because cloud communication surfaces are always addressed by viewId.","triggerScenarios":"A close event for a `cloud-communication-core` modal whose `view` is absent or has no `viewId` — e.g. a payload carrying only `view.id`, which the announcements module would accept but this subclass rejects.","commonSituations":"Reusing announcement-banner payload shapes on cloud communication modals; fixtures with `view: {}`; fields lost in serialization.","solutions":["Send the modal's identifier as `payload: { view: { viewId } }`.","Do not assume the legacy `id` fallback applies — this app requires `viewId`.","Verify the payload shape with a type guard before dispatch."],"exampleFix":"// before (works for cloud-announcements-core, fails here)\npayload: { view: { id: modalId }, triggerId }\n\n// after\npayload: { view: { viewId: modalId }, triggerId }","handlingStrategy":"validation","validationCode":"if (!payload.payload?.view?.viewId) {\n  throw new Error('cloud-communication-core close requires view.viewId');\n}\nawait cloudCommunicationModule.viewClosed(payload);","typeGuard":"const hasStrictViewId = (\n  payload: UiKitCoreAppViewClosedPayload,\n): payload is UiKitCoreAppViewClosedPayload & { payload: { view: { viewId: string } } } =>\n  Boolean(payload.payload?.view?.viewId);","tryCatchPattern":"try {\n  await cloudCommunicationModule.viewClosed(payload);\n} catch (error) {\n  if (error instanceof Error && error.message === 'invalid view') {\n    // view.id alone is not enough here: rebuild with view.viewId\n  }\n}","preventionTips":["This app requires viewId strictly — do not rely on the id fallback","Derive viewId from the modal that was actually opened"],"tags":["uikit","cloud","subscription","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-14T05:17:10.506Z"}