RocketChat/Rocket.Chat · error · Error
The "start" query parameter must be before the "end" query p
Error message
The "start" query parameter must be before the "end" query parameter.
What it means
checkDates requires start not to be after end (equal dates pass; only strictly-after fails). This is the last date check, running after validity and the 1-year span check, on every livechat/analytics/dashboards/* report route.
Source
Thrown at apps/meteor/ee/server/api/v1/omnichannel/reports.ts:29
} 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',
{
authRequired: true,
permissionsRequired: ['view-livechat-reports'],
validateParams: isGETDashboardConversationsByType,
license: ['livechat-enterprise'],
},
{
async get() {
const { start, end } = this.queryParams;
const startDate = moment(start);
const endDate = moment(end);
View on GitHub (pinned to b2c16d5842)
Solutions
- Order the pair before sending: send min(start,end) as start and max(start,end) as end.
- Check the UI binding for swapped from/to fields.
- Log the exact query string when dashboard requests fail to catch silent swaps.
Example fix
// before
api.get(url, { params: { start, end } }); // user picked end before start
// after
const [s, e] = start.isAfter(end) ? [end, start] : [start, end];
api.get(url, { params: { start: s.toISOString(), end: e.toISOString() } }); Defensive patterns
Strategy: validation
Validate before calling
const [s, e] = start.isAfter(end) ? [end, start] : [start, end];
await api.get(url, { params: { start: s.toISOString(), end: e.toISOString() } }); Prevention
- Sort the pair before sending; only strictly-after fails, equal dates are fine.
- Beware timezone conversions that push start past end at day boundaries.
- Log the final query string to catch swapped params in UI refactors.
When it happens
Trigger: GET .../conversations-by-source?start=2024-06-30&end=2024-01-01, or a client sending {from, to} in the wrong order after a refactor.
Common situations: Swapped query params; timezone conversion pushing a client's 'today' start past the server-parsed end; date pickers defaulting start to tomorrow; end truncated to midnight while start keeps a late-evening time.
Related errors
- The "start" and "end" query parameters must be less than 1 y
- The "start" query parameter must be a valid date.
- The "end" query parameter must be a valid date.
- error-duplicate-priority-name
- error-room-does-not-exist
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/9158d10d1dbb8bd5.
Report an issue: GitHub.