RocketChat/Rocket.Chat · error · Error
The " .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 GET /api/v1/livechat/rooms when the JSON-encoded date-range query parameter (typically 'created' or 'closed', e.g. created={"start":"...","end":"..."}) parses as JSON but its start value is not a parseable date — Date.parse(start) is NaN. The property name is interpolated into the message so the client knows which parameter failed.
Solutions
- Generate the range programmatically: JSON.stringify({ start: d1.toISOString(), end: d2.toISOString() }) and encodeURIComponent it
- Validate with Date.parse on the client before sending; skip the filter when the value is invalid
- Use ISO-8601 (yyyy-MM-dd or full ISO timestamps); avoid locale-specific formats
Example fix
// before
const q = `created=${JSON.stringify({ start: '01/12/2024', end: '31/12/2024' })}`; // dd/mm/yyyy → NaN
// after
const range = { start: new Date('2024-12-01').toISOString(), end: new Date('2024-12-31').toISOString() };
if (Number.isNaN(Date.parse(range.start)) || Number.isNaN(Date.parse(range.end))) throw new Error('bad range');
const q = `created=${encodeURIComponent(JSON.stringify(range))}`; Defensive patterns
Strategy: validation
Validate before calling
function toRangeParam(d1, d2) {
const range = {};
if (d1 instanceof Date && !Number.isNaN(d1.getTime())) range.start = d1.toISOString();
if (d2 instanceof Date && !Number.isNaN(d2.getTime())) range.end = d2.toISOString();
return Object.keys(range).length ? encodeURIComponent(JSON.stringify(range)) : '';
} Type guard
function isValidRangeValue(v) {
return typeof v === 'string' && v.length > 0 && !Number.isNaN(Date.parse(v));
} Prevention
- Only serialize Date objects that pass !isNaN(getTime())
- Always use ISO-8601 from toISOString(), never locale strings
- encodeURIComponent the whole JSON payload
When it happens
Trigger: Passing created=%7B%22start%22%3A%222024-13-01%22%7D (invalid month), a start like '2024/31/12', an empty-ish or malformed string, or a timestamp with a bad timezone suffix; also passing a bare string instead of a JSON object when the code expects {start}.
Common situations: Clients building the filter with toISOString on invalid Date objects (NaN dates serialize to 'Invalid Date' or 'null'); locale-formatted dates (dd/mm/yyyy) from user-facing date pickers; hand-crafted query strings missing URL-encoding, which corrupts the JSON before it reaches the server.
Related errors
- The " .end" query parameter must be a valid date.
- error-token-param-not-provided
- Invalid custom fields
- The "customFields" query parameter must be a valid JSON.
- agent-not-found
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/44fac02a4eef8772.
Report an issue: GitHub.
Appendix: 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 b2c16d5842)