RocketChat/Rocket.Chat · warning · Error
The "${property}.end" query parameter must be a valid date.
Error message
The "${property}.end" query parameter must be a valid date. What it means
Thrown by validateDateParams in GET livechat/rooms when the createdAt/closedAt JSON param has an `.end` field that Date.parse cannot interpret. Symmetric with the .start check; only the field name in the message differs. Any non-empty end value failing Date.parse triggers it.
Source
Thrown at apps/meteor/server/api/v1/omnichannel/rooms.ts:19
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;
const createdAtParam = validateDateParams('createdAt', createdAt);
const closedAtParam = validateDateParams('closedAt', closedAt);View on GitHub (pinned to f9d3ec372b)
Solutions
- Always send end as ISO 8601, matching the start format.
- If end is optional, omit it from the JSON object instead of sending null or empty string.
- Client-side guard: `if (end && isNaN(Date.parse(end))) warnUser();`.
- URL-encode the serialized JSON query param.
Example fix
// before
GET('/api/v1/livechat/rooms?createdAt=' + JSON.stringify({ start: '2021-01-01', end: userInputEnd }));
// after
const endIso = userInputEnd ? new Date(userInputEnd).toISOString() : undefined;
const range = endIso ? { start: startIso, end: endIso } : { start: startIso };
GET('/api/v1/livechat/rooms?createdAt=' + encodeURIComponent(JSON.stringify(range))); 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', { closedAt: buildDateParam(start, end) });
} catch (e) {
if (/must be a valid date/i.test(e.message)) { showDateError(); return; }
throw e;
} Prevention
- Use ISO 8601 for both start and end consistently.
- Omit end when unneeded instead of sending null/empty.
- URL-encode the JSON param.
When it happens
Trigger: GET livechat/rooms?closedAt={"start":"2021-01-01","end":"tomorrow"} — the end value 'tomorrow' (or any non-ISO string) is rejected. Same risk for relative words, locale dates, or malformed numbers.
Common situations: Range filter where the user picked a start date but typed/omitted end date in free text; client sends end as a Unix epoch number-as-string the parser rejects; mismatched date formats between start and end.
Related errors
- The "${property}.start" 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/5ca93d50f504d3d2.
Report an issue: GitHub.