RocketChat/Rocket.Chat · warning · Error
The "${property}.start" query parameter must be a valid date
Error message
The "${property}.start" query parameter must be a valid date. What it means
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.
Source
Thrown at apps/meteor/server/api/v1/omnichannel/rooms.ts:16
import { LivechatRooms } from '@rocket.chat/models';
import { isGETLivechatRoomsParams } from '@rocket.chat/rest-typings';
import { API } from '../..';
import { findRooms } from './lib/rooms';
import { hasPermissionAsync } from '../../../lib/authorization/hasPermission';
import { getPaginationItems } from '../../lib/getPaginationItems';
const validateDateParams = (property: string, date?: string) => {
let parsedDate: { start?: string; end?: string } | undefined = undefined;
if (date) {
parsedDate = JSON.parse(date) as { start?: string; end?: string };
}
if (parsedDate?.start && isNaN(Date.parse(parsedDate.start))) {
throw new Error(`The "${property}.start" query parameter must be a valid date.`);
}
if (parsedDate?.end && isNaN(Date.parse(parsedDate.end))) {
throw new Error(`The "${property}.end" query parameter must be a valid date.`);
}
return parsedDate;
};
const isBoolean = (value?: string | boolean): boolean => value === 'true' || value === 'false' || typeof value === 'boolean';
API.v1.addRoute(
'livechat/rooms',
{ authRequired: true, validateParams: isGETLivechatRoomsParams },
{
async get() {
const { offset, count } = await getPaginationItems(this.queryParams);
const { sort, fields, query } = await this.parseJsonQuery();
const { agents, departmentId, open, tags, roomName, onhold, queued, units } = this.queryParams;
const { createdAt, customFields, closedAt } = this.queryParams;View on GitHub (pinned to f9d3ec372b)
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.
Example fix
// before
GET('/api/v1/livechat/rooms?createdAt=' + JSON.stringify({ start: userInput }));
// after
const iso = new Date(userInput).toISOString();
if (isNaN(Date.parse(iso))) throw new ClientError('bad date');
GET('/api/v1/livechat/rooms?createdAt=' + encodeURIComponent(JSON.stringify({ start: iso, end: isoEnd }))); Defensive patterns
Strategy: validation
Validate before calling
function buildDateParam(start?: string, end?: string) {
const out: { start?: string; end?: string } = {};
if (start) { if (isNaN(Date.parse(start))) throw new ClientError('bad start'); out.start = new Date(start).toISOString(); }
if (end) { if (isNaN(Date.parse(end))) throw new ClientError('bad end'); out.end = new Date(end).toISOString(); }
return Object.keys(out).length ? JSON.stringify(out) : undefined;
} Type guard
const isIsoDate = (s: unknown): s is string => typeof s === 'string' && !isNaN(Date.parse(s));
Try / catch
try {
await GET('/api/v1/livechat/rooms', { createdAt: buildDateParam(start, end) });
} catch (e) {
if (/must be a valid date/i.test(e.message)) { showDateError(); return; }
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The "${property}.end" query parameter must be a valid date.
- The "customFields" query parameter must be a valid JSON.
- invalid-chart-name
- error-contact-not-found
- error-visitor-not-found
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/44fac02a4eef8772.
Report an issue: GitHub.