RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-subscription

error-invalid-subscription

Error message

Invalid subscription

What it means

In the ignoreUser helper, Subscriptions.findOneByRoomIdAndUserId(rid, fromUserId) found nothing: the calling user has no subscription (membership) record in that room. The method refuses to apply an ignore in a room the caller does not belong to; both caller and target must be members.

Source

Thrown at apps/meteor/server/meteor-methods/users/ignoreUser.ts:26

declare module '@rocket.chat/ddp-client' {
	// eslint-disable-next-line @typescript-eslint/naming-convention
	interface ServerMethods {
		ignoreUser(params: { rid: string; userId: string; ignore?: boolean }): boolean;
	}
}

export const ignoreUser = async (
	fromUserId: string,
	{ rid, userId: ignoredUser, ignore }: { rid: string; userId: string; ignore?: boolean },
): Promise<boolean> => {
	const [subscription, subscriptionIgnoredUser] = await Promise.all([
		Subscriptions.findOneByRoomIdAndUserId(rid, fromUserId),
		Subscriptions.findOneByRoomIdAndUserId(rid, ignoredUser),
	]);

	if (!subscription) {
		throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', {
			method: 'ignoreUser',
		});
	}

	if (!subscriptionIgnoredUser) {
		throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', {
			method: 'ignoreUser',
		});
	}

	const result = await Subscriptions.ignoreUser({ _id: subscription._id, ignoredUser, ignore });

	if (result.modifiedCount) {
		void notifyOnSubscriptionChangedById(subscription._id);
	}

	return !!result;
};

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Join/rejoin the room before using ignore within it
  2. Pass the rid of the room currently open and verify the caller's subscription exists first
  3. Refresh room subscriptions before showing the ignore action

Example fix

// before
Meteor.callAsync('ignoreUser', { rid, userId: ignoredUser, ignore: true });

// after
const mySub = Subscriptions.findOne({ rid });
if (!mySub) {
	showNotice('join the room before ignoring users here');
	return;
}
await Meteor.callAsync('ignoreUser', { rid, userId: ignoredUser, ignore: true });
Defensive patterns

Strategy: validation

Validate before calling

const mySub = Subscriptions.findOne({ rid });
if (!mySub) {
	showNotice('You are not a member of this room');
	return;
}
await Meteor.callAsync('ignoreUser', { rid, userId: ignoredUser, ignore: true });

Try / catch

try {
	await Meteor.callAsync('ignoreUser', { rid, userId, ignore: true });
} catch (err) {
	if ((err as { error?: string }).error === 'error-invalid-subscription') {
		// caller's membership missing — refresh subscriptions or rejoin
	}
}

Prevention

When it happens

Trigger: Ignoring a user in a room the caller never joined, left, or was removed from; passing a rid from a different room than the one currently displayed.

Common situations: Stale UI passing an old rid after the user switched rooms; ignore actions offered from global search results where the room context is wrong; subscription purged when the user left the room.

Related errors


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