{"record":{"id":"2168f8e52a58c729","repo":"RocketChat/Rocket.Chat","slug":"error-team-not-found-2168f8","errorCode":"error-team-not-found","errorMessage":"The \"teamId\" param provided does not match any team","messagePattern":"The \"teamId\" param provided does not match any team","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/createPrivateGroup.ts","lineNumber":42,"sourceCode":"\tuser: IUser,\n\tname: string,\n\tmembers: string[],\n\treadOnly = false,\n\tcustomFields?: Record<string, any>,\n\textraData: Record<string, any> = {},\n\texcludeSelf = false,\n): Promise<\n\tICreatedRoom & {\n\t\trid: string;\n\t}\n> => {\n\tcheck(name, String);\n\tcheck(members, Match.Optional([String]));\n\n\tif (extraData.teamId) {\n\t\tconst team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(extraData.teamId, { projection: { roomId: 1 } });\n\t\tif (!team) {\n\t\t\tthrow new Meteor.Error('error-team-not-found', 'The \"teamId\" param provided does not match any team', {\n\t\t\t\tmethod: 'createPrivateGroup',\n\t\t\t});\n\t\t}\n\t\tif (!(await hasPermissionAsync(user, 'create-team-group', team.roomId))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createPrivateGroup' });\n\t\t}\n\t} else if (!(await hasPermissionAsync(user, 'create-p'))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createPrivateGroup' });\n\t}\n\n\treturn createRoom('p', name, user, members, excludeSelf, readOnly, {\n\t\t...(customFields && Object.keys(customFields).length && { customFields }),\n\t\t...extraData,\n\t});\n};\n\nMeteor.methods<ServerMethods>({\n\tasync createPrivateGroup(name, members, readOnly = false, customFields = {}, extraData = {}) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/createPrivateGroup.ts#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"Team deleted while the creation dialog was open; integrations confusing the team room id with the team _id; stale team pickers in the UI.","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."],"exampleFix":"// before\nMeteor.call('createPrivateGroup', name, members, false, {}, { teamId });\n\n// after\nconst res = await getTeamInfo(teamId); // GET /api/v1/teams.info\nif (!res?.success) {\n  throw new Error('Team no longer exists');\n}\nMeteor.call('createPrivateGroup', name, members, false, {}, { teamId: res.teamInfo._id });","handlingStrategy":"validation","validationCode":"// resolve the team right before creating the private group\nconst res = await getTeamInfo(teamId); // GET /api/v1/teams.info\nif (!res?.success) {\n  // teamId stale - refresh the team list instead of calling createPrivateGroup\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('createPrivateGroup', name, members, false, {}, { teamId });\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-team-not-found') {\n    // re-fetch teams and retry once with a current id\n    const fresh = await refreshTeams();\n    return Meteor.callAsync('createPrivateGroup', name, members, false, {}, { teamId: fresh.id });\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["rocket-chat","meteor","create-private-group","teams","team-id","not-found"],"backgroundTag":"team-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}