RocketChat/Rocket.Chat · error · Error

invalid view

Error message

invalid view

What it means

`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.

Source

Thrown at apps/meteor/server/modules/core-apps/cloudSubscriptionCommunication.module.ts:20

import type * as UiKit from '@rocket.chat/ui-kit';

import { CloudAnnouncementsModule } from './cloudAnnouncements.module';

export class CloudSubscriptionCommunication extends CloudAnnouncementsModule {
	override appId = 'cloud-communication-core';

	override async viewClosed(payload: UiKitCoreAppViewClosedPayload): Promise<UiKit.ServerInteraction> {
		const {
			payload: { view: { viewId } = {} },
			user: { _id: userId } = {},
		} = payload;

		if (!userId) {
			throw new Error('invalid user');
		}

		if (!viewId) {
			throw new Error('invalid view');
		}

		if (!payload.triggerId) {
			throw new Error('invalid triggerId');
		}

		// for viewClosed we just need to let Cloud know that the banner was closed, no need to wait for the response

		void this.handlePayload(payload);

		return {
			type: 'modal.close',
			triggerId: payload.triggerId,
			appId: payload.appId,
		};
	}
}

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Send the modal's identifier as `payload: { view: { viewId } }`.
  2. Do not assume the legacy `id` fallback applies — this app requires `viewId`.
  3. Verify the payload shape with a type guard before dispatch.

Example fix

// before (works for cloud-announcements-core, fails here)
payload: { view: { id: modalId }, triggerId }

// after
payload: { view: { viewId: modalId }, triggerId }
Defensive patterns

Strategy: validation

Validate before calling

if (!payload.payload?.view?.viewId) {
  throw new Error('cloud-communication-core close requires view.viewId');
}
await cloudCommunicationModule.viewClosed(payload);

Type guard

const hasStrictViewId = (
  payload: UiKitCoreAppViewClosedPayload,
): payload is UiKitCoreAppViewClosedPayload & { payload: { view: { viewId: string } } } =>
  Boolean(payload.payload?.view?.viewId);

Try / catch

try {
  await cloudCommunicationModule.viewClosed(payload);
} catch (error) {
  if (error instanceof Error && error.message === 'invalid view') {
    // view.id alone is not enough here: rebuild with view.viewId
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: Reusing announcement-banner payload shapes on cloud communication modals; fixtures with `view: {}`; fields lost in serialization.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/7ac7b8fc0707b073. Report an issue: GitHub.