RocketChat/Rocket.Chat · error · Meteor.Error

error-team-not-found

error-team-not-found

Error message

The "teamId" param provided does not match any team

What it means

createChannel guard for team-linked channels: extraData.teamId was provided but Team.findOneById(extraData.teamId) returned null, so the team the new channel should belong to does not exist. The method aborts with error-team-not-found ('The teamId param provided does not match any team') before any create-team-channel permission check.

Source

Thrown at apps/meteor/server/meteor-methods/rooms/createChannel.ts:47

	customFields?: Record<string, any>,
	extraData: Record<string, any> = {},
	excludeSelf = false,
) => {
	check(name, String);
	check(members, Match.Optional([String]));
	if (!userId) {
		throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'createChannel' });
	}

	const user = await Users.findOneById(userId, { projection: { services: 0 } });
	if (!user?.username) {
		throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'createChannel' });
	}

	if (extraData.teamId) {
		const team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(extraData.teamId, { projection: { roomId: 1 } });
		if (!team) {
			throw new Meteor.Error('error-team-not-found', 'The "teamId" param provided does not match any team', { method: 'createChannel' });
		}
		if (!(await hasPermissionAsync(userId, 'create-team-channel', team.roomId))) {
			throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createChannel' });
		}
	} else if (!(await hasPermissionAsync(userId, 'create-c'))) {
		throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createChannel' });
	}

	return createRoom('c', name, user, members, excludeSelf, readOnly, {
		...(customFields && Object.keys(customFields).length && { customFields }),
		...extraData,
	});
};

Meteor.methods<ServerMethods>({
	async createChannel(name, members, readOnly = false, customFields = {}, extraData = {}) {
		methodDeprecationLogger.method('createChannel', '9.0.0', '/v1/channels.create');
		const uid = Meteor.userId();

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Re-resolve the team right before the call (GET /api/v1/teams.info or teams.list) and use its current _id.
  2. Omit teamId when creating a plain, non-team channel.
  3. If the team was deleted, recreate it or create the channel standalone.

Example fix

// before
Meteor.call('createChannel', name, members, false, {}, { teamId });

// after
const res = await getTeamInfo(teamId); // GET /api/v1/teams.info
if (!res?.success) {
  throw new Error('Team no longer exists');
}
Meteor.call('createChannel', name, members, false, {}, { teamId: res.teamInfo._id });
Defensive patterns

Strategy: validation

Validate before calling

// resolve the team right before creating the channel
const res = await getTeamInfo(teamId); // GET /api/v1/teams.info
if (!res?.success) {
  // teamId stale - refresh the team list instead of calling createChannel
}

Try / catch

try {
  await Meteor.callAsync('createChannel', name, members, false, {}, { teamId });
} catch (e) {
  if (e instanceof Meteor.Error && e.error === 'error-team-not-found') {
    // re-fetch teams and retry once with a current id
    const fresh = await refreshTeams();
    return Meteor.callAsync('createChannel', name, members, false, {}, { teamId: fresh.id });
  }
  throw e;
}

Prevention

When it happens

Trigger: Meteor.call('createChannel', name, members, readOnly, customFields, { teamId }) where teamId is stale (team deleted), is the team name or the team's room id instead of the team _id, or is mistyped.

Common situations: UI holding an old teamId from a deleted team; integrations confusing the team room id with the team _id; race between team deletion elsewhere and channel creation here.

Related errors


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