RocketChat/Rocket.Chat · error · Error
The "start" query parameter must be a valid date.
Error message
The "start" query parameter must be a valid date.
What it means
Every GET livechat/analytics/dashboards/* report route (conversations-by-source, -status, -department, -tags, -agent, ...) runs checkDates(start, end) on the moment-parsed query params. If start cannot be parsed into a valid moment (missing, empty, or unrecognized format), this error is thrown before the cached aggregation runs.
Source
Thrown at apps/meteor/ee/server/api/v1/omnichannel/reports.ts:17
import { isGETDashboardConversationsByType } from '@rocket.chat/rest-typings';
import type { Moment } from 'moment';
import moment from 'moment';
import {
findAllConversationsBySourceCached,
findAllConversationsByStatusCached,
findAllConversationsByDepartmentCached,
findAllConversationsByTagsCached,
findAllConversationsByAgentsCached,
} from './lib/dashboards';
import { API } from '../../../../../server/api';
import { restrictQuery } from '../../../lib/omnichannel/restrictQuery';
const checkDates = (start: Moment, end: Moment) => {
if (!start.isValid()) {
throw new Error('The "start" query parameter must be a valid date.');
}
if (!end.isValid()) {
throw new Error('The "end" query parameter must be a valid date.');
}
// Check dates are no more than 1 year apart using moment
// 1.01 === "we allow to pass year by some hours/days"
if (moment(end).startOf('day').diff(moment(start).startOf('day'), 'year', true) > 1.01) {
throw new Error('The "start" and "end" query parameters must be less than 1 year apart.');
}
if (start.isAfter(end)) {
throw new Error('The "start" query parameter must be before the "end" query parameter.');
}
};
API.v1.addRoute(
'livechat/analytics/dashboards/conversations-by-source',
{View on GitHub (pinned to b2c16d5842)
Solutions
- Send start as ISO 8601, e.g. 2024-01-01T00:00:00.000Z or 2024-01-01.
- Always include both start and end, non-empty.
- Normalize dates client-side (moment/date-fns) before building the query string.
Example fix
// before
api.get('/v1/livechat/analytics/dashboards/conversations-by-source', { params: { start: 'yesterday', end } });
// after
api.get('/v1/livechat/analytics/dashboards/conversations-by-source', {
params: { start: moment(start).toISOString(), end: moment(end).toISOString() },
}); Defensive patterns
Strategy: validation
Validate before calling
const isIsoDate = (v: string | undefined): v is string => !!v && !Number.isNaN(Date.parse(v));
if (!isIsoDate(start) || !isIsoDate(end)) {
throw new Error('start and end must be valid ISO 8601 dates');
}
await api.get(url, { params: { start, end } }); Try / catch
try {
await api.get(url, { params: { start, end } });
} catch (e) {
if (e?.response?.data?.error === 'The "start" query parameter must be a valid date.') {
// normalize start to ISO 8601 and retry once
} else throw e;
} Prevention
- Serialize dates with toISOString() before building query strings.
- Make both bounds required in your client types.
- Reject free-text date input in UIs feeding these reports.
When it happens
Trigger: GET /api/v1/livechat/analytics/dashboards/conversations-by-source?start=abc&end=2024-01-01, or omitting start / sending an empty value, so moment(start).isValid() is false.
Common situations: Passing human dates ('yesterday', '01/02/2024' in an unexpected locale format); leaving the param out because the dashboard UI normally fills it; copy-pasted values with trailing spaces or smart quotes.
Related errors
- The "end" query parameter must be a valid date.
- The "start" and "end" query parameters must be less than 1 y
- The "start" query parameter must be before the "end" query p
- The "${property}.start" query parameter must be a valid date
- The "${property}.end" query parameter must be a valid date.
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/fdbceefac676e6a4.
Report an issue: GitHub.