RocketChat/Rocket.Chat · error · Meteor.Error

error-message-size-exceeded

error-message-size-exceeded

Error message

error-message-size-exceeded

What it means

Thrown by POST rooms.mediaConfirm when the 'description' body field length exceeds the Message_MaxAllowedSize setting. The description becomes the message text attached to the uploaded file, so it shares the same message-size cap as regular messages.

Source

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

);

API.v1.addRoute(
	'rooms.mediaConfirm/:rid/:fileId',
	{ authRequired: true },
	{
		async post() {
			if (!(await canAccessRoomIdAsync(this.urlParams.rid, this.userId))) {
				return API.v1.forbidden();
			}

			const file = await Uploads.findOneByIdAndUserIdAndRoomId(this.urlParams.fileId, this.userId, this.urlParams.rid);

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

			if ((this.bodyParams.description?.length ?? 0) > settings.get<number>('Message_MaxAllowedSize')) {
				throw new Meteor.Error('error-message-size-exceeded');
			}

			file.description = this.bodyParams.description;
			delete this.bodyParams.description;

			if (this.bodyParams.fileName) {
				file.name = this.bodyParams.fileName;
				delete this.bodyParams.fileName;
			}

			if (this.bodyParams.fileContent) {
				file.content = this.bodyParams.fileContent;
				delete this.bodyParams.fileContent;
			}

			await applyAirGappedRestrictionsValidation(() =>
				sendFileMessage(this.userId, { roomId: this.urlParams.rid, file, msgData: this.bodyParams }),
			);

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Truncate the description to <= Message_MaxAllowedSize before sending (read it via settings or a conservative hard cap).
  2. Move long text into the message body of a follow-up message instead of the file description.
  3. Raise Message_MaxAllowedSize in admin settings if business needs require longer captions.

Example fix

// before
await rest.post(url, { description: longText });

// after
const MAX = settings.Message_MaxAllowedSize ?? 5000;
await rest.post(url, { description: longText.slice(0, MAX) });
Defensive patterns

Strategy: validation

Validate before calling

const MAX = await fetchMessageMaxAllowedSize(); // from public settings
const safeDescription = description.length > MAX ? description.slice(0, MAX) : description;

Type guard

function fitsMessageSize(s: string, max: number): boolean {
  return typeof s === 'string' && s.length <= max;
}

Try / catch

try {
  await rest.post(url, { description });
} catch (e) {
  if (isMeteorError(e, 'error-message-size-exceeded')) {
    await rest.post(url, { description: description.slice(0, MAX) });
  } else throw e;
}

Prevention

When it happens

Trigger: POST /api/v1/rooms.mediaConfirm/:rid/:fileId with a 'description' string longer than the admin-configured Message_MaxAllowedSize.

Common situations: Pasting a long caption or auto-generated transcript as the description; Message_MaxAllowedSize lowered by admins after the client was written; copying a full email body as a file caption.

Related errors


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