{"record":{"id":"f2e4208e018a6fc0","repo":"RocketChat/Rocket.Chat","slug":"error-updatedsince-param-invalid","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/chat.ts","lineNumber":1156,"sourceCode":"\t\t\t\t\t},\n\t\t\t\t\trequired: ['threads', '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 { rid } = this.queryParams;\n\t\t\tconst { query, fields, sort } = await this.parseJsonQuery();\n\t\t\tconst { updatedSince } = this.queryParams;\n\t\t\tlet updatedSinceDate;\n\t\t\tif (!settings.get<boolean>('Threads_enabled')) {\n\t\t\t\tthrow new Meteor.Error('error-not-allowed', 'Threads Disabled');\n\t\t\t}\n\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\tconst user = await Users.findOneById(this.userId, { projection: { _id: 1 } });\n\t\t\tconst room = await Rooms.findOneById(rid, { projection: { ...roomAccessAttributes, t: 1, _id: 1 } });\n\n\t\t\tif (!room || !user || !(await canAccessRoomAsync(room, user))) {\n\t\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not Allowed');\n\t\t\t}\n\t\t\tconst threadQuery = Object.assign({}, query, { rid, tcount: { $exists: true } });\n\t\t\treturn API.v1.success({\n\t\t\t\tthreads: {\n\t\t\t\t\tupdate: await Messages.find(\n\t\t\t\t\t\t{ ...threadQuery, _updatedAt: { $gt: updatedSinceDate } },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsort,\n\t\t\t\t\t\t\tprojection: fields,\n\t\t\t\t\t\t},","sourceCodeStart":1138,"sourceCodeEnd":1174,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/chat.ts#L1138-L1174","documentation":"Thrown by GET chat.syncThreadsList when updatedSince is supplied but Date.parse(updatedSince) is NaN. Checked at chat.ts:1155. Note: the check fires only when updatedSince is truthy but unparseable; an empty updatedSince is treated as 'no delta' and does not throw here.","triggerScenarios":"GET /api/v1/chat.syncThreadsList?rid=...&updatedSince=1717200000 (epoch number as string), updatedSince=06/01/2024, or any non-ISO format.","commonSituations":"Same date-format pitfalls as error 365: non-ISO formatter, missing 'Z' suffix, locale string, URL-encoding mangling.","solutions":["Send updatedSince as ISO-8601 UTC: 2024-06-01T00:00:00.000Z.","Generate via new Date().toISOString() and URL-encode the result.","If you want a full snapshot (no delta), omit updatedSince entirely rather than sending garbage."],"exampleFix":"// before\nGET /api/v1/chat.syncThreadsList?rid=GENERAL&updatedSince=1717200000\n// after\nGET /api/v1/chat.syncThreadsList?rid=GENERAL&updatedSince=2024-06-01T00:00:00.000Z","handlingStrategy":"validation","validationCode":"function toIsoUpdatedSince(v: string | number | Date): string {\n  const d = v instanceof Date ? v : new Date(v);\n  if (isNaN(d.getTime())) {\n    throw new Error('updatedSince must be a valid ISO date; got: ' + String(v));\n  }\n  return d.toISOString();\n}\n\nu.searchParams.set('updatedSince', toIsoUpdatedSince(lastThreadSync));","typeGuard":"const isValidIsoDate = (s: unknown): boolean =>\n  typeof s === 'string' && !isNaN(Date.parse(s));","tryCatchPattern":"try {\n  await GET(syncThreadsUrl);\n} catch (e) {\n  if ((e as any)?.error === 'error-updatedSince-param-invalid') {\n    // reset cursor to a known-good ISO value and retry once\n  }\n  throw e;\n}","preventionTips":["Serialize with toISOString() and URL-encode the value.","Omit updatedSince entirely for a full snapshot instead of sending garbage.","Validate on the client before dispatching the sync request."],"tags":["api","rest","validation","query-params","date","threads","chat","sync"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}