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
createPrivateGroup guard for team-linked groups: extraData.teamId was supplied but Team.findOneById(extraData.teamId) returned null. The private group cannot be attached to a nonexistent team, so the method aborts with error-team-not-found ('The teamId param provided does not match any team') before the create-team-group permission check.
Source
Thrown at apps/meteor/server/meteor-methods/rooms/createPrivateGroup.ts:42
user: IUser,
name: string,
members: string[],
readOnly = false,
customFields?: Record<string, any>,
extraData: Record<string, any> = {},
excludeSelf = false,
): Promise<
ICreatedRoom & {
rid: string;
}
> => {
check(name, String);
check(members, Match.Optional([String]));
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: 'createPrivateGroup',
});
}
if (!(await hasPermissionAsync(user, 'create-team-group', team.roomId))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createPrivateGroup' });
}
} else if (!(await hasPermissionAsync(user, 'create-p'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createPrivateGroup' });
}
return createRoom('p', name, user, members, excludeSelf, readOnly, {
...(customFields && Object.keys(customFields).length && { customFields }),
...extraData,
});
};
Meteor.methods<ServerMethods>({
async createPrivateGroup(name, members, readOnly = false, customFields = {}, extraData = {}) {View on GitHub (pinned to b2c16d5842)
Solutions
- Refresh the team and pass its current _id (GET /api/v1/teams.info).
- Omit teamId for standalone private groups.
- Re-create the team if it was deleted and is still required.
Example fix
// before
Meteor.call('createPrivateGroup', 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('createPrivateGroup', name, members, false, {}, { teamId: res.teamInfo._id }); Defensive patterns
Strategy: validation
Validate before calling
// resolve the team right before creating the private group
const res = await getTeamInfo(teamId); // GET /api/v1/teams.info
if (!res?.success) {
// teamId stale - refresh the team list instead of calling createPrivateGroup
} Try / catch
try {
await Meteor.callAsync('createPrivateGroup', 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('createPrivateGroup', name, members, false, {}, { teamId: fresh.id });
}
throw e;
} Prevention
- Pass the team _id as teamId - never the team name or the team room id.
- Refresh the team picker data when the dialog may have been open across team deletions.
- Omit teamId for private groups that should not belong to a team.
When it happens
Trigger: Meteor.call('createPrivateGroup', name, members, readOnly, customFields, { teamId }) with a stale id from a deleted team, the team name instead of its _id, or a typo.
Common situations: Team deleted while the creation dialog was open; integrations confusing the team room id with the team _id; stale team pickers in the UI.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/2168f8e52a58c729.
Report an issue: GitHub.