RocketChat/Rocket.Chat · warning · Meteor.Error

The required "mid" body param is missing.

The required "mid" body param is missing.

Error message

The required "mid" body param is missing.

What it means

Thrown by chat.followMessage when this.bodyParams.mid is falsy. Notably the thrown value is a Meteor.Error whose code IS the full message string ('The required "mid" body param is missing.') rather than a stable error code - so client matching must compare against the literal string, not a symbolic code. The body is also parsed through isChatFollowMessageLocalProps before this, so reaching this throw suggests the schema allowed a missing mid.

Source

Thrown at apps/meteor/server/api/v1/chat.ts:481

				401: validateUnauthorizedErrorResponse,
				200: ajv.compile<void>({
					type: 'object',
					properties: {
						success: {
							type: 'boolean',
							enum: [true],
						},
					},
					required: ['success'],
					additionalProperties: false,
				}),
			},
		},
		async function action() {
			const { mid } = this.bodyParams;

			if (!mid) {
				throw new Meteor.Error('The required "mid" body param is missing.');
			}

			await followMessage(this.user, { mid });

			return API.v1.success();
		},
	)
	.post(
		'chat.unfollowMessage',
		{
			authRequired: true,
			body: isChatUnfollowMessageLocalProps,
			response: {
				400: validateBadRequestErrorResponse,
				401: validateUnauthorizedErrorResponse,
				200: ajv.compile<void>({
					type: 'object',
					properties: {

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Always include mid in the request body for chat.followMessage.
  2. Tighten the body schema (isChatFollowMessageLocalProps) to require mid, so the framework returns a 400 before the action runs.
  3. Match on the literal message string in the client (there is no symbolic code).

Example fix

// before
throw new Meteor.Error('The required "mid" body param is missing.');

// after - stable code + human message
throw new Meteor.Error('error-param-required', 'The required "mid" body param is missing.');

// and enforce it in the schema so the action never sees a missing mid:
// const isChatFollowMessageLocalProps = ajv.compile({
//   type: 'object',
//   properties: { mid: { type: 'string' } },
//   required: ['mid'],
//   additionalProperties: false,
// });
Defensive patterns

Strategy: validation

Validate before calling

function requireMid(body) {
  if (!body || typeof body.mid !== 'string' || body.mid.trim() === '') {
    throw new Error('The "mid" body param is required');
  }
  return body.mid;
}

Type guard

function hasValidMid(body) {
  return Boolean(body) && typeof body.mid === 'string' && body.mid.trim().length > 0;
}

Try / catch

try {
  await api.followMessage({ mid });
} catch (e) {
  // No symbolic code - match the literal message
  if (e.error === 'The required "mid" body param is missing.' || /mid.*required/.test(e.message)) {
    highlightFollowError();
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: POST chat.followMessage with no mid in the body, an empty string mid, or a body the schema validator passed through without binding mid.

Common situations: Client omitting mid; form field named differently (e.g., messageId instead of mid); AJV schema for the body not requiring mid, letting the action reach this manual guard.

Related errors


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