RocketChat/Rocket.Chat · error · Meteor.Error

error-updatedSince-param-invalid

error-updatedSince-param-invalid

Error message

The "updatedSince" query parameter must be a valid date.

What it means

Thrown by GET rooms.get when an 'updatedSince' query parameter is supplied but Date.parse() returns NaN. The route uses updatedSince to return only rooms changed since a cursor; an unparseable value breaks the cursor contract. Provide an ISO-8601 timestamp or omit the parameter entirely to get a full snapshot.

Source

Thrown at apps/meteor/server/api/v1/rooms.ts:244

				properties: {
					update: { type: 'array', items: { type: 'object' } }, // relaxed: IRoom composed with lastMessage
					remove: { type: 'array', items: { type: 'object' } }, // relaxed: IRoom composed with lastMessage
					success: { type: 'boolean', enum: [true] },
				},
				required: ['update', 'remove', 'success'],
				additionalProperties: false,
			}),
			400: validateBadRequestErrorResponse,
			401: validateUnauthorizedErrorResponse,
		},
	},
	async function action() {
		const { updatedSince } = this.queryParams;

		let updatedSinceDate;
		if (updatedSince) {
			if (isNaN(Date.parse(updatedSince))) {
				throw new Meteor.Error('error-updatedSince-param-invalid', 'The "updatedSince" query parameter must be a valid date.');
			} else {
				updatedSinceDate = new Date(updatedSince);
			}
		}

		let result = await roomsGetMethod(this.userId, updatedSinceDate);

		if (Array.isArray(result)) {
			result = {
				update: result,
				remove: [],
			};
		}

		return API.v1.success({
			update: await Promise.all(result.update.map((room) => composeRoomWithLastMessage(room, this.userId))),
			remove: await Promise.all(result.remove.map((room) => composeRoomWithLastMessage(room, this.userId))),
		});

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Send updatedSince as ISO-8601 UTC, e.g. new Date().toISOString() → '2024-01-01T00:00:00.000Z'.
  2. If you want all rooms, omit updatedSince entirely.
  3. Validate with Date.parse on the client before sending and drop or fix the param if NaN.
  4. Check for URL-encoding mistakes (the ':' in the timestamp must be encoded or sent correctly).

Example fix

// before
const since = Date.now();              // a number, not parseable as intended
rest.get(`/api/v1/rooms.get?updatedSince=${since}`);

// after
const since = new Date().toISOString(); // ISO-8601 string
rest.get(`/api/v1/rooms.get?updatedSince=${encodeURIComponent(since)}`);
Defensive patterns

Strategy: validation

Validate before calling

function buildRoomsGetUrl(updatedSince?: string): string {
  if (updatedSince && isNaN(Date.parse(updatedSince))) {
    throw new Error(`updatedSince is not a valid date: ${updatedSince}`);
  }
  const q = updatedSince ? `?updatedSince=${encodeURIComponent(updatedSince)}` : '';
  return `/api/v1/rooms.get${q}`;
}

Type guard

function isValidIsoDate(s: unknown): s is string {
  return typeof s === 'string' && !isNaN(Date.parse(s));
}

Try / catch

try {
  await rest.get(url);
} catch (e) {
  if (isMeteorError(e, 'error-updatedSince-param-invalid')) {
    // retry without the cursor to get a full snapshot
    await rest.get('/api/v1/rooms.get');
  } else throw e;
}

Prevention

When it happens

Trigger: GET /api/v1/rooms.get?updatedSince=<garbage> where the value is not parseable by Date.parse (e.g. a Unix number without a date format, locale strings, empty-ish garbage, or a malformed ISO string). Anything Date.parse cannot handle triggers it.

Common situations: Passing a Unix epoch number instead of an ISO string; using toLocaleDateString() output; URL-encoding errors that mangle the timestamp; copying a 'lastUpdate' value from another API that uses a different format.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/ebe277bb25e9b027. Report an issue: GitHub.