{"record":{"id":"ebe277bb25e9b027","repo":"RocketChat/Rocket.Chat","slug":"error-updatedsince-param-invalid-ebe277","errorCode":"error-updatedSince-param-invalid","errorMessage":"The \"updatedSince\" query parameter must be a valid date.","messagePattern":"The \"updatedSince\" query parameter must be a valid date\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":244,"sourceCode":"\t\t\t\tproperties: {\n\t\t\t\t\tupdate: { type: 'array', items: { type: 'object' } }, // relaxed: IRoom composed with lastMessage\n\t\t\t\t\tremove: { type: 'array', items: { type: 'object' } }, // relaxed: IRoom composed with lastMessage\n\t\t\t\t\tsuccess: { type: 'boolean', enum: [true] },\n\t\t\t\t},\n\t\t\t\trequired: ['update', 'remove', 'success'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t}),\n\t\t\t400: validateBadRequestErrorResponse,\n\t\t\t401: validateUnauthorizedErrorResponse,\n\t\t},\n\t},\n\tasync function action() {\n\t\tconst { updatedSince } = this.queryParams;\n\n\t\tlet updatedSinceDate;\n\t\tif (updatedSince) {\n\t\t\tif (isNaN(Date.parse(updatedSince))) {\n\t\t\t\tthrow new Meteor.Error('error-updatedSince-param-invalid', 'The \"updatedSince\" query parameter must be a valid date.');\n\t\t\t} else {\n\t\t\t\tupdatedSinceDate = new Date(updatedSince);\n\t\t\t}\n\t\t}\n\n\t\tlet result = await roomsGetMethod(this.userId, updatedSinceDate);\n\n\t\tif (Array.isArray(result)) {\n\t\t\tresult = {\n\t\t\t\tupdate: result,\n\t\t\t\tremove: [],\n\t\t\t};\n\t\t}\n\n\t\treturn API.v1.success({\n\t\t\tupdate: await Promise.all(result.update.map((room) => composeRoomWithLastMessage(room, this.userId))),\n\t\t\tremove: await Promise.all(result.remove.map((room) => composeRoomWithLastMessage(room, this.userId))),\n\t\t});","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/rooms.ts#L226-L262","documentation":"Thrown by GET rooms.get when an 'updatedSince' query parameter is supplied but Date.parse() returns NaN. The route uses updatedSince to return only rooms changed since a cursor; an unparseable value breaks the cursor contract. Provide an ISO-8601 timestamp or omit the parameter entirely to get a full snapshot.","triggerScenarios":"GET /api/v1/rooms.get?updatedSince=<garbage> where the value is not parseable by Date.parse (e.g. a Unix number without a date format, locale strings, empty-ish garbage, or a malformed ISO string). Anything Date.parse cannot handle triggers it.","commonSituations":"Passing a Unix epoch number instead of an ISO string; using toLocaleDateString() output; URL-encoding errors that mangle the timestamp; copying a 'lastUpdate' value from another API that uses a different format.","solutions":["Send updatedSince as ISO-8601 UTC, e.g. new Date().toISOString() → '2024-01-01T00:00:00.000Z'.","If you want all rooms, omit updatedSince entirely.","Validate with Date.parse on the client before sending and drop or fix the param if NaN.","Check for URL-encoding mistakes (the ':' in the timestamp must be encoded or sent correctly)."],"exampleFix":"// before\nconst since = Date.now();              // a number, not parseable as intended\nrest.get(`/api/v1/rooms.get?updatedSince=${since}`);\n\n// after\nconst since = new Date().toISOString(); // ISO-8601 string\nrest.get(`/api/v1/rooms.get?updatedSince=${encodeURIComponent(since)}`);","handlingStrategy":"validation","validationCode":"function buildRoomsGetUrl(updatedSince?: string): string {\n  if (updatedSince && isNaN(Date.parse(updatedSince))) {\n    throw new Error(`updatedSince is not a valid date: ${updatedSince}`);\n  }\n  const q = updatedSince ? `?updatedSince=${encodeURIComponent(updatedSince)}` : '';\n  return `/api/v1/rooms.get${q}`;\n}","typeGuard":"function isValidIsoDate(s: unknown): s is string {\n  return typeof s === 'string' && !isNaN(Date.parse(s));\n}","tryCatchPattern":"try {\n  await rest.get(url);\n} catch (e) {\n  if (isMeteorError(e, 'error-updatedSince-param-invalid')) {\n    // retry without the cursor to get a full snapshot\n    await rest.get('/api/v1/rooms.get');\n  } else throw e;\n}","preventionTips":["Always source updatedSince from new Date().toISOString().","URL-encode the timestamp.","Drop the param when you want a full snapshot."],"tags":["rest-api","rooms","validation","date-format"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}