{"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":715,"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":697,"sourceCodeEnd":733,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/chat.ts#L697-L733","documentation":"Thrown by GET chat.syncMessages when the required 'roomId' query parameter is missing. The endpoint also requires either 'type' or 'lastUpdate' (see error 364). roomId is checked first at chat.ts:716; without it the history/sync query cannot be scoped.","triggerScenarios":"GET /api/v1/chat.syncMessages without a roomId query string, or with roomId spelled 'rid'/'room'/'room_id'. Query params must be URL-encoded in the query string, not the JSON body.","commonSituations":"Confusing this GET endpoint with POST endpoints that take rid in the body; passing the room id as a path segment; SDK version that names the param differently.","solutions":["Append ?roomId=<GENERAL> to the GET chat.syncMessages URL.","Also include either lastUpdate (ISO date) or type to satisfy error 364.","Use the canonical room _id from rooms.info, not the room name."],"exampleFix":"// before\nGET /api/v1/chat.syncMessages?rid=GENERAL\n// after\nGET /api/v1/chat.syncMessages?roomId=GENERAL&lastUpdate=2024-01-01T00:00:00Z","handlingStrategy":"validation","validationCode":"function buildSyncUrl(roomId: string, opts: { lastUpdate?: string; type?: string }) {\n  if (!roomId) throw new Error('roomId query param is required for chat.syncMessages');\n  const u = new URL('/api/v1/chat.syncMessages', location.origin);\n  u.searchParams.set('roomId', roomId);\n  if (opts.lastUpdate) u.searchParams.set('lastUpdate', opts.lastUpdate);\n  else if (opts.type) u.searchParams.set('type', opts.type);\n  else throw new Error('either lastUpdate or type is required');\n  return u;\n}","typeGuard":"const hasRoomId = (q: Record<string, unknown>): q is { roomId: string } & Record<string, unknown> =>\n  typeof q.roomId === 'string' && q.roomId.length > 0;","tryCatchPattern":"try {\n  await GET(buildSyncUrl(roomId, opts));\n} catch (e) {\n  if ((e as any)?.error === 'error-param-required' && /roomId/.test(String((e as any)?.reason))) {\n    // roomId missing — fix caller before retry\n  }\n  throw e;\n}","preventionTips":["Use URLSearchParams / a typed client so params land in the query string, not the body.","Always pair roomId with lastUpdate or type.","Reuse one URL-builder helper across sync calls."],"tags":["api","rest","validation","query-params","chat","sync"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}