{"record":{"id":"44fac02a4eef8772","repo":"RocketChat/Rocket.Chat","slug":"the-property-start-query-parameter-must-be-a","errorCode":null,"errorMessage":"The \"${property}.start\" query parameter must be a valid date.","messagePattern":"The \"(.+?)\\.start\" query parameter must be a valid date\\.","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"warning","filePath":"apps/meteor/server/api/v1/omnichannel/rooms.ts","lineNumber":16,"sourceCode":"import { LivechatRooms } from '@rocket.chat/models';\nimport { isGETLivechatRoomsParams } from '@rocket.chat/rest-typings';\n\nimport { API } from '../..';\nimport { findRooms } from './lib/rooms';\nimport { hasPermissionAsync } from '../../../lib/authorization/hasPermission';\nimport { getPaginationItems } from '../../lib/getPaginationItems';\n\nconst validateDateParams = (property: string, date?: string) => {\n\tlet parsedDate: { start?: string; end?: string } | undefined = undefined;\n\tif (date) {\n\t\tparsedDate = JSON.parse(date) as { start?: string; end?: string };\n\t}\n\n\tif (parsedDate?.start && isNaN(Date.parse(parsedDate.start))) {\n\t\tthrow new Error(`The \"${property}.start\" query parameter must be a valid date.`);\n\t}\n\tif (parsedDate?.end && isNaN(Date.parse(parsedDate.end))) {\n\t\tthrow new Error(`The \"${property}.end\" query parameter must be a valid date.`);\n\t}\n\treturn parsedDate;\n};\n\nconst isBoolean = (value?: string | boolean): boolean => value === 'true' || value === 'false' || typeof value === 'boolean';\n\nAPI.v1.addRoute(\n\t'livechat/rooms',\n\t{ authRequired: true, validateParams: isGETLivechatRoomsParams },\n\t{\n\t\tasync get() {\n\t\t\tconst { offset, count } = await getPaginationItems(this.queryParams);\n\t\t\tconst { sort, fields, query } = await this.parseJsonQuery();\n\t\t\tconst { agents, departmentId, open, tags, roomName, onhold, queued, units } = this.queryParams;\n\t\t\tconst { createdAt, customFields, closedAt } = this.queryParams;","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/omnichannel/rooms.ts#L1-L34","documentation":"Thrown by the validateDateParams helper used in GET livechat/rooms when the createdAt (or closedAt) JSON query param has a `.start` field that Date.parse cannot interpret as a valid date. The helper JSON.parses the param then validates start/end with Date.parse; an unparseable start string throws this.","triggerScenarios":"GET livechat/rooms?createdAt={\"start\":\"2021-13-99\",\"end\":\"...\"} or any start value Date.parse rejects (e.g. 'foo', '2021/02/30', epoch in wrong format). Note JSON.parse itself can also throw SyntaxError before this check if the param is malformed JSON.","commonSituations":"Client formats dates inconsistently (locale-specific strings, MM/DD/YYYY vs ISO 8601); user typed a free-text date into a filter; frontend sends an empty object {\"start\":\"\"} that should have been omitted; timezone offset string the parser rejects.","solutions":["Send createdAt/closedAt as JSON with ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) start/end values.","Omit the param entirely when no filter is desired rather than sending an empty or partial object.","Validate the date string client-side with `!isNaN(Date.parse(value))` before serializing to the query.","URL-encode the JSON string when sending as a query parameter."],"exampleFix":"// before\nGET('/api/v1/livechat/rooms?createdAt=' + JSON.stringify({ start: userInput }));\n\n// after\nconst iso = new Date(userInput).toISOString();\nif (isNaN(Date.parse(iso))) throw new ClientError('bad date');\nGET('/api/v1/livechat/rooms?createdAt=' + encodeURIComponent(JSON.stringify({ start: iso, end: isoEnd })));","handlingStrategy":"validation","validationCode":"function buildDateParam(start?: string, end?: string) {\n  const out: { start?: string; end?: string } = {};\n  if (start) { if (isNaN(Date.parse(start))) throw new ClientError('bad start'); out.start = new Date(start).toISOString(); }\n  if (end) { if (isNaN(Date.parse(end))) throw new ClientError('bad end'); out.end = new Date(end).toISOString(); }\n  return Object.keys(out).length ? JSON.stringify(out) : undefined;\n}","typeGuard":"const isIsoDate = (s: unknown): s is string => typeof s === 'string' && !isNaN(Date.parse(s));","tryCatchPattern":"try {\n  await GET('/api/v1/livechat/rooms', { createdAt: buildDateParam(start, end) });\n} catch (e) {\n  if (/must be a valid date/i.test(e.message)) { showDateError(); return; }\n  throw e;\n}","preventionTips":["Always serialize dates to ISO 8601 before placing them in query params.","Omit the param entirely rather than sending empty objects.","URL-encode JSON query param values."],"tags":["omnichannel","livechat","query-params","date-validation","rooms-list"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}