RocketChat/Rocket.Chat · error · Error

error-invalid-description

error-invalid-description

Error message

error-invalid-description

What it means

reportMessage requires a non-blank reason: description.trim() must be truthy, otherwise it throws plain Error('error-invalid-description'). Moderation reports must carry report text, so empty or whitespace-only descriptions are rejected before the message is even looked up.

Source

Thrown at apps/meteor/server/lib/moderation/reportMessage.ts:13

import { Apps, AppEvents } from '@rocket.chat/apps';
import type { IMessage, IUser } from '@rocket.chat/core-typings';
import { Messages, ModerationReports, Rooms, Users } from '@rocket.chat/models';

import { canAccessRoomAsync } from '../authorization/canAccessRoom';

export const reportMessage = async (messageId: IMessage['_id'], description: string, uid: IUser['_id']) => {
	if (!uid) {
		throw new Error('error-invalid-user');
	}

	if (!description.trim()) {
		throw new Error('error-invalid-description');
	}

	const message = await Messages.findOneById(messageId);

	if (!message) {
		throw new Error('error-invalid-message_id');
	}

	const user = await Users.findOneById(uid);

	if (!user) {
		throw new Error('error-invalid-user');
	}

	const { rid } = message;
	// If the user can't access the room where the message is, report that the message id is invalid
	const room = await Rooms.findOneById(rid);
	if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Require non-empty report text in the UI and disable submit until filled
  2. Trim and length-check the description client-side before calling
  3. In integrations, default to a meaningful reason string instead of sending blank

Example fix

// before
await reportMessage(messageId, '   ', uid); // whitespace-only

// after
const reason = description.trim();
if (!reason) return focusReportTextarea();
await reportMessage(messageId, reason, uid);
Defensive patterns

Strategy: validation

Validate before calling

const reason = description.trim();
if (reason.length > 0) {
  await reportMessage(messageId, reason, uid);
} else {
  return requireReportText();
}

Type guard

const hasReportText = (description: string): boolean =>
  typeof description === 'string' && description.trim().length > 0;

Try / catch

try {
  await reportMessage(messageId, description, uid);
} catch (e) {
  if (e instanceof Error && e.message === 'error-invalid-description') {
    focusReportTextarea(); // keep the dialog open and ask for a reason
  }
}

Prevention

When it happens

Trigger: reportMessage(msgId, '', uid) or a whitespace-only description: the client submitted the report dialog without text, or an integration sent no reason.

Common situations: Report UI with an optional-looking message box; automated abuse-report scripts sending empty descriptions; users entering only spaces to bypass the dialog.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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