{"record":{"id":"441f187c5b1ec95c","repo":"RocketChat/Rocket.Chat","slug":"error-team-not-found","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":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/createChannel.ts","lineNumber":47,"sourceCode":"\tcustomFields?: Record<string, any>,\n\textraData: Record<string, any> = {},\n\texcludeSelf = false,\n) => {\n\tcheck(name, String);\n\tcheck(members, Match.Optional([String]));\n\tif (!userId) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'createChannel' });\n\t}\n\n\tconst user = await Users.findOneById(userId, { projection: { services: 0 } });\n\tif (!user?.username) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'createChannel' });\n\t}\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', { method: 'createChannel' });\n\t\t}\n\t\tif (!(await hasPermissionAsync(userId, 'create-team-channel', team.roomId))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createChannel' });\n\t\t}\n\t} else if (!(await hasPermissionAsync(userId, 'create-c'))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createChannel' });\n\t}\n\n\treturn createRoom('c', 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 createChannel(name, members, readOnly = false, customFields = {}, extraData = {}) {\n\t\tmethodDeprecationLogger.method('createChannel', '9.0.0', '/v1/channels.create');\n\t\tconst uid = Meteor.userId();","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/createChannel.ts#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-resolve the team right before the call (GET /api/v1/teams.info or teams.list) and use its current _id.","Omit teamId when creating a plain, non-team channel.","If the team was deleted, recreate it or create the channel standalone."],"exampleFix":"// before\nMeteor.call('createChannel', 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('createChannel', name, members, false, {}, { teamId: res.teamInfo._id });","handlingStrategy":"validation","validationCode":"// resolve the team right before creating the channel\nconst res = await getTeamInfo(teamId); // GET /api/v1/teams.info\nif (!res?.success) {\n  // teamId stale - refresh the team list instead of calling createChannel\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('createChannel', 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('createChannel', 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.","Re-resolve the team id when the selection UI data is older than the current session.","Omit teamId entirely for plain, non-team channels."],"tags":["rocket-chat","meteor","create-channel","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"}