{"record":{"id":"6da07533c96acd09","repo":"RocketChat/Rocket.Chat","slug":"error-roomid-param-not-provided-6da075","errorCode":"error-roomid-param-not-provided","errorMessage":"The parameter \"roomId\" or \"roomName\" is required","messagePattern":"The parameter \"roomId\" or \"roomName\" is required","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":114,"sourceCode":"\nexport async function findRoomByIdOrName({\n\tparams,\n\tcheckedArchived = true,\n}: {\n\tparams:\n\t\t| {\n\t\t\t\troomId?: string;\n\t\t  }\n\t\t| {\n\t\t\t\troomName?: string;\n\t\t  };\n\tcheckedArchived?: boolean;\n}): Promise<IRoom> {\n\tif (\n\t\t(!('roomId' in params) && !('roomName' in params)) ||\n\t\t('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)\n\t) {\n\t\tthrow new Meteor.Error('error-roomid-param-not-provided', 'The parameter \"roomId\" or \"roomName\" is required');\n\t}\n\n\tconst projection = { ...API.v1.defaultFieldsToExclude };\n\n\tlet room;\n\tif ('roomId' in params) {\n\t\troom = await Rooms.findOneById(params.roomId || '', { projection });\n\t} else if ('roomName' in params) {\n\t\troom = await Rooms.findOneByName(params.roomName || '', { projection });\n\t}\n\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-room-not-found', 'The required \"roomId\" or \"roomName\" param provided does not match any channel');\n\t}\n\tif (checkedArchived && room.archived) {\n\t\tthrow new Meteor.Error('error-room-archived', `The channel, ${room.name}, is archived`);\n\t}\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/rooms.ts#L96-L132","documentation":"Thrown by the shared helper findRoomByIdOrName when neither roomId nor roomName is present in params (or both are present but empty). The helper powers several room endpoints that accept either an id or a name. Returns a structured Meteor.Error('error-roomid-param-not-provided', ...).","triggerScenarios":"Calling an endpoint backed by findRoomByIdOrName with a body/query containing neither roomId nor roomName, or containing both as empty strings.","commonSituations":"Client conditionally builds params and sends an empty object; both fields left blank in a form; param name typo (e.g. room instead of roomName).","solutions":["Supply exactly one of roomId or roomName as a non-empty string.","Validate at least one identifier is present client-side before the call.","Use roomId when you have the internal id; use roomName for the human-readable channel name."],"exampleFix":"// before\nfetch('/api/v1/<endpoint>', { method:'POST', body: JSON.stringify({}) });\n\n// after\nif (!roomId && !roomName) throw new Error('roomId or roomName required');\nconst body = roomId ? { roomId } : { roomName };\nfetch('/api/v1/<endpoint>', { method:'POST', body: JSON.stringify(body) });","handlingStrategy":"validation","validationCode":"function buildRoomParam(roomId?: string, roomName?: string): { roomId: string } | { roomName: string } {\n  if (roomId && roomId.trim()) return { roomId };\n  if (roomName && roomName.trim()) return { roomName };\n  throw new Error('roomId or roomName is required');\n}\nconst body = buildRoomParam(roomId, roomName);","typeGuard":"type RoomRef = { roomId: string } | { roomName: string };\nfunction isRoomRef(p: unknown): p is RoomRef {\n  if (typeof p !== 'object' || p === null) return false;\n  const o = p as Record<string, unknown>;\n  return (typeof o.roomId === 'string' && o.roomId.length > 0) || (typeof o.roomName === 'string' && o.roomName.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Always send exactly one non-empty identifier.","Validate the union client-side before posting."],"tags":["rooms","rest-api","validation","query-params"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}