RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-channel

error-invalid-channel

Error message

Invalid channel

What it means

Thrown by updateIncomingIntegration's validateChannels when integration.channel is missing, not a string, or blank (all three conditions combined at one throw site, line 27). Unlike a partial-update API, this DDP method requires the full channel string on every update call - omitting channel to 'keep it as is' fails here.

Source

Thrown at apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts:27

import { compileIntegrationScript } from '../../../lib/integrations/lib/compileIntegrationScript';
import { isScriptEngineFrozen, validateScriptEngine } from '../../../lib/integrations/lib/validateScriptEngine';
import { notifyOnIntegrationChanged } from '../../../lib/notifyListener';

const validChannelChars = ['@', '#'];

declare module '@rocket.chat/ddp-client' {
	// eslint-disable-next-line @typescript-eslint/naming-convention
	interface ServerMethods {
		updateIncomingIntegration(
			integrationId: string,
			integration: INewIncomingIntegration | IUpdateIncomingIntegration,
		): IIntegration | null;
	}
}

function validateChannels(channelString: string | undefined): string[] {
	if (!channelString || typeof channelString.valueOf() !== 'string' || channelString.trim() === '') {
		throw new Meteor.Error('error-invalid-channel', 'Invalid channel', {
			method: 'updateIncomingIntegration',
		});
	}

	const channels = channelString.split(',').map((channel) => channel.trim());

	for (const channel of channels) {
		if (!validChannelChars.includes(channel[0])) {
			throw new Meteor.Error('error-invalid-channel-start-with-chars', 'Invalid channel. Start with @ or #', {
				method: 'updateIncomingIntegration',
			});
		}
	}

	return channels;
}

export const updateIncomingIntegration = async (

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Always include the complete comma-separated channel string ('#room,@user') in the update payload, echoing the integration's current channels when unchanged
  2. Load the current integration first (GET /api/v1/integrations.list) and reuse its channel list joined with ','
  3. Migrate to the REST endpoint /v1/integrations.update before 9.0.0 removes the method

Example fix

// before: partial update, channel omitted
await Meteor.callAsync('updateIncomingIntegration', id, { enabled: true }); // -> error-invalid-channel
// after: include current channels
await Meteor.callAsync('updateIncomingIntegration', id, { enabled: true, channel: current.channel.join(',') });
Defensive patterns

Strategy: validation

Validate before calling

const current = await Meteor.callAsync('listIncomingIntegrations').then((r) => r.integrations.find((i) => i._id === integrationId));
const channel = integration.channel ?? current.channel.join(','); // always send a full channel string
if (typeof channel !== 'string' || channel.trim() === '') throw new Error('channel is required on update');
await Meteor.callAsync('updateIncomingIntegration', integrationId, { ...integration, channel });

Type guard

const hasChannelString = (p: { channel?: unknown }): p is { channel: string } => typeof p.channel === 'string' && p.channel.trim() !== '';

Try / catch

try {
  await Meteor.callAsync('updateIncomingIntegration', integrationId, integration);
} catch (err) {
  if (err instanceof Meteor.Error && err.error === 'error-invalid-channel') { /* merge current channels into payload and resubmit */ }
}

Prevention

When it happens

Trigger: Meteor.callAsync('updateIncomingIntegration', id, { name: 'new-name' }) with no channel key; an edit form that submits an empty channel field; passing channel as an array of room objects.

Common situations: Developers assuming PATCH-like semantics on a method that validates channel unconditionally; UI edit screens where clearing the channel input sends ''; migration from /api/v1/integrations.update which likewise requires channel.

Related errors


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