RocketChat/Rocket.Chat · error · Meteor.Error

message-length-exceeds-character-limit

message-length-exceeds-character-limit

Error message

message-length-exceeds-character-limit

What it means

Livechat messages are length-checked when Livechat_enable_message_character_limit is enabled: if msg.length exceeds parseInt(Livechat_message_character_limit) the send aborts with message-length-exceeds-character-limit. The limit applies only to the livechat guest message body, checked before the message is stored.

Source

Thrown at apps/meteor/server/meteor-methods/omnichannel/sendMessageLivechat.ts:60

			username: String,
		}),
	);

	const guest = await LivechatVisitors.getVisitorByToken(token, {
		projection: {
			name: 1,
			username: 1,
			department: 1,
			token: 1,
		},
	});

	if (!guest) {
		throw new Meteor.Error('invalid-token');
	}

	if (settings.get('Livechat_enable_message_character_limit') && msg.length > parseInt(settings.get('Livechat_message_character_limit'))) {
		throw new Meteor.Error('message-length-exceeds-character-limit');
	}

	return sendMessage({
		guest,
		message: {
			_id,
			rid,
			msg,
			token,
			file,
			files,
			attachments,
		},
		agent,
		roomInfo: {
			source: {
				type: OmnichannelSourceType.API,
			},

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Truncate or split the message client-side before sending, respecting the configured limit
  2. Raise Livechat_message_character_limit or disable Livechat_enable_message_character_limit if the workflow needs longer messages
  3. Show a character counter in the widget so guests see the cap before sending

Example fix

// before
Meteor.call('sendMessageLivechat', { token, _id, rid, msg: fullText });

// after
const limit = parseInt(settings.get('Livechat_message_character_limit'), 10);
const msg = fullText.slice(0, limit);
Meteor.call('sendMessageLivechat', { token, _id, rid, msg });
Defensive patterns

Strategy: validation

Validate before calling

const limitOn = settings.get('Livechat_enable_message_character_limit');
const limit = parseInt(settings.get('Livechat_message_character_limit'), 10);
if (limitOn && text.length > limit) {
  text = text.slice(0, limit); // or surface a counter and block submission
}

Type guard

const isLengthExceeded = (e: unknown): e is Meteor.Error =>
  typeof e === 'object' && e !== null && (e as { error?: string }).error === 'message-length-exceeds-character-limit';

Try / catch

try {
  await send(text);
} catch (e) {
  if (isLengthExceeded(e)) {
    for (let i = 0; i < text.length; i += limit) {
      await send(text.slice(i, i + limit)); // chunked resend
    }
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: A visitor sending a message longer than Livechat_message_character_limit while Livechat_enable_message_character_limit is on; integrations forwarding long transcripts or email bodies into livechat without truncation.

Common situations: Admins enable a low character cap for spam control; support widgets fed by automated systems that send unbounded text; the limit lowered after go-live, breaking previously working integrations.

Related errors


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