{"record":{"id":"e7c8c332b5b90f9b","repo":"RocketChat/Rocket.Chat","slug":"error-type-param-required","errorCode":"error-type-param-required","errorMessage":"The \"type\" parameter is required when using the \"next\" or \"previous\" parameters","messagePattern":"The \"type\" parameter is required when using the \"next\" or \"previous\" parameters","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/publications/messages.ts","lineNumber":249,"sourceCode":"\t\t\tcursor?: {\n\t\t\t\tnext: string | null;\n\t\t\t\tprevious: string | null;\n\t\t\t};\n\t  }\n\t| false\n\t| IMessage[]\n\t| { messages: IMessage[]; firstUnread?: any; unreadNotLoaded?: number }\n> => {\n\tif (!(await canAccessRoomIdAsync(rid, fromId))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'messages/get' });\n\t}\n\n\tif (type && !['UPDATED', 'DELETED'].includes(type)) {\n\t\tthrow new Meteor.Error('error-type-param-not-supported', 'The \"type\" parameter must be either \"UPDATED\" or \"DELETED\"');\n\t}\n\n\tif ((next || previous) && !type) {\n\t\tthrow new Meteor.Error('error-type-param-required', 'The \"type\" parameter is required when using the \"next\" or \"previous\" parameters');\n\t}\n\n\tif (next && previous) {\n\t\tthrow new Meteor.Error('error-cursor-conflict', 'You cannot provide both \"next\" and \"previous\" parameters');\n\t}\n\n\tif ((next || previous) && lastUpdate) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-cursor-and-lastUpdate-conflict',\n\t\t\t'The attributes \"next\", \"previous\" and \"lastUpdate\" cannot be used together',\n\t\t);\n\t}\n\n\t// `fromTs` only bounds the query on the `lastUpdate` path; neither cursor pagination nor the channel\n\t// history fallback honors it, so accepting it there would silently widen the result set.\n\tif (fromTs && !lastUpdate) {\n\t\tthrow new Meteor.Error('error-fromTs-requires-lastUpdate', 'The \"fromTs\" parameter can only be used together with \"lastUpdate\"');\n\t}","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/publications/messages.ts#L231-L267","documentation":"messages/get requires the type parameter whenever next or previous (cursor pagination) is used, because the cursor indexes a different collection per type — live messages for UPDATED, the trash collection for DELETED. Omitting it throws Meteor.Error 'error-type-param-required'.","triggerScenarios":"Calling messages/get with next or previous set but no type parameter.","commonSituations":"Clients that copy the cursor fields out of a response but forget to carry the type they paged with; adding cursor paging incrementally to an existing integration.","solutions":["Always send type: 'UPDATED' or 'DELETED' together with next/previous","Persist the type alongside the cursor in your paging state so both travel together","When adding cursor pagination, update both the request builder and the state store"],"exampleFix":"// before\nMeteor.call('messages/get', rid, { next: cursor.next }); // throws error-type-param-required\n\n// after\nMeteor.call('messages/get', rid, { type: 'UPDATED', next: cursor.next });","handlingStrategy":"validation","validationCode":"const hasTypeForCursor = (params: { next?: string; previous?: string; type?: string }): boolean =>\n  !(params.next || params.previous) || Boolean(params.type);","typeGuard":"type CursorParams = { type: 'UPDATED' | 'DELETED'; next?: string } | { type: 'UPDATED' | 'DELETED'; previous?: string };\n\nconst isCursorParams = (p: unknown): p is CursorParams => {\n  const v = p as CursorParams;\n  return (v.type === 'UPDATED' || v.type === 'DELETED') && !(v.next && v.previous);\n};","tryCatchPattern":null,"preventionTips":["Store type together with the cursor in paging state so they always travel as a pair","Validate that any request containing next/previous also contains a valid type before sending","Add the type parameter at the same time you adopt cursor pagination, not later"],"tags":["pagination","messages-api","parameter-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}