{"record":{"id":"386267d8011e8749","repo":"RocketChat/Rocket.Chat","slug":"error-param-required","errorCode":"error-param-required","errorMessage":"The required \"roomId\" query param is missing","messagePattern":"The required \"roomId\" query param is missing","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/chat.ts","lineNumber":719,"sourceCode":"\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trequired: ['updated', 'deleted'],\n\t\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsuccess: { type: 'boolean', enum: [true] },\n\t\t\t\t\t},\n\t\t\t\t\trequired: ['result', 'success'],\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t}),\n\t\t\t\t400: validateBadRequestErrorResponse,\n\t\t\t\t401: validateUnauthorizedErrorResponse,\n\t\t\t},\n\t\t},\n\t\tasync function action() {\n\t\t\tconst { roomId, lastUpdate, fromTs, count, next, previous, type } = this.queryParams;\n\n\t\t\tif (!roomId) {\n\t\t\t\tthrow new Meteor.Error('error-param-required', 'The required \"roomId\" query param is missing');\n\t\t\t}\n\n\t\t\tif (!lastUpdate && !type) {\n\t\t\t\tthrow new Meteor.Error('error-param-required', 'The \"type\" or \"lastUpdate\" parameters must be provided');\n\t\t\t}\n\n\t\t\tif (lastUpdate && isNaN(Date.parse(lastUpdate))) {\n\t\t\t\tthrow new Meteor.Error('error-lastUpdate-param-invalid', 'The \"lastUpdate\" query parameter must be a valid date');\n\t\t\t}\n\n\t\t\tconst getMessagesQuery = {\n\t\t\t\t...(lastUpdate && { lastUpdate: new Date(lastUpdate) }),\n\t\t\t\t...(fromTs && { fromTs: new Date(fromTs) }),\n\t\t\t\t...(next && { next }),\n\t\t\t\t...(previous && { previous }),\n\t\t\t\t...(count && { count }),\n\t\t\t\t...(type && { type }),\n\t\t\t};","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/chat.ts#L701-L737","documentation":"Thrown by GET chat.syncMessages (apps/meteor/server/api/v1/chat.ts:715) when the roomId query param is falsy, with error-param-required. The endpoint's query schema requires roomId as a string with no minLength, so an empty roomId= passes validation and only dies here; a fully missing roomId is normally caught by schema validation first (this guard is the handler-level backstop and the documented error for older builds).","triggerScenarios":"GET /api/v1/chat.syncMessages?roomId= (empty value), or on servers without query validation a request with no roomId at all. Also when a URL builder drops the param (undefined stringified) or the roomId variable is empty before templating.","commonSituations":"Sync loops where roomId comes from a config/room list and one entry is blank; query-string encoders that omit empty values inconsistently; clients written before the endpoint enforced query schemas.","solutions":["Always include a real room id: GET /api/v1/chat.syncMessages?roomId=GENERAL&lastUpdate=2024-01-01T00:00:00Z.","Validate roomId is a non-empty string client-side before building the URL.","Skip blank entries in room lists feeding the sync loop.","Fetch the room id from rooms.info/rooms.list at startup rather than hardcoding."],"exampleFix":"// before\nconst url = `/api/v1/chat.syncMessages?roomId=${rid}`; // rid === '' -> error\n\n// after\nif (!rid) throw new Error('roomId required');\nconst url = `/api/v1/chat.syncMessages?roomId=${encodeURIComponent(rid)}`;","handlingStrategy":"validation","validationCode":"if (typeof roomId !== 'string' || roomId.trim() === '') throw new Error('roomId query param is required');\nawait rc.get('/api/v1/chat.syncMessages', { params: { roomId, lastUpdate } });","typeGuard":"const hasRoomId = (p: Record<string, unknown>): p is { roomId: string } =>\n  typeof p.roomId === 'string' && p.roomId.length > 0;","tryCatchPattern":"try {\n  await rc.get('/api/v1/chat.syncMessages', { params });\n} catch (e) {\n  if (e?.errorType === 'error-param-required') skipRoom(params.roomId); // blank entry, log and continue\n  else throw e;\n}","preventionTips":["Filter blank room ids out of sync-loops before scheduling requests.","Build query strings with a params serializer that omits undefined (not empty) values."],"tags":["rocket-chat","rest-api","sync","missing-parameter","chat-syncmessages"],"backgroundTag":"missing-required-argument","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}