{"record":{"id":"a2dedc168ea60425","repo":"RocketChat/Rocket.Chat","slug":"error-message-size-exceeded","errorCode":"error-message-size-exceeded","errorMessage":"error-message-size-exceeded","messagePattern":"error-message-size-exceeded","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":342,"sourceCode":");\n\nAPI.v1.addRoute(\n\t'rooms.mediaConfirm/:rid/:fileId',\n\t{ authRequired: true },\n\t{\n\t\tasync post() {\n\t\t\tif (!(await canAccessRoomIdAsync(this.urlParams.rid, this.userId))) {\n\t\t\t\treturn API.v1.forbidden();\n\t\t\t}\n\n\t\t\tconst file = await Uploads.findOneByIdAndUserIdAndRoomId(this.urlParams.fileId, this.userId, this.urlParams.rid);\n\n\t\t\tif (!file) {\n\t\t\t\tthrow new Meteor.Error('invalid-file');\n\t\t\t}\n\n\t\t\tif ((this.bodyParams.description?.length ?? 0) > settings.get<number>('Message_MaxAllowedSize')) {\n\t\t\t\tthrow new Meteor.Error('error-message-size-exceeded');\n\t\t\t}\n\n\t\t\tfile.description = this.bodyParams.description;\n\t\t\tdelete this.bodyParams.description;\n\n\t\t\tif (this.bodyParams.fileName) {\n\t\t\t\tfile.name = this.bodyParams.fileName;\n\t\t\t\tdelete this.bodyParams.fileName;\n\t\t\t}\n\n\t\t\tif (this.bodyParams.fileContent) {\n\t\t\t\tfile.content = this.bodyParams.fileContent;\n\t\t\t\tdelete this.bodyParams.fileContent;\n\t\t\t}\n\n\t\t\tawait applyAirGappedRestrictionsValidation(() =>\n\t\t\t\tsendFileMessage(this.userId, { roomId: this.urlParams.rid, file, msgData: this.bodyParams }),\n\t\t\t);","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/rooms.ts#L324-L360","documentation":"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.","triggerScenarios":"POST /api/v1/rooms.mediaConfirm/:rid/:fileId with a 'description' string longer than the admin-configured Message_MaxAllowedSize.","commonSituations":"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.","solutions":["Truncate the description to <= Message_MaxAllowedSize before sending (read it via settings or a conservative hard cap).","Move long text into the message body of a follow-up message instead of the file description.","Raise Message_MaxAllowedSize in admin settings if business needs require longer captions."],"exampleFix":"// before\nawait rest.post(url, { description: longText });\n\n// after\nconst MAX = settings.Message_MaxAllowedSize ?? 5000;\nawait rest.post(url, { description: longText.slice(0, MAX) });","handlingStrategy":"validation","validationCode":"const MAX = await fetchMessageMaxAllowedSize(); // from public settings\nconst safeDescription = description.length > MAX ? description.slice(0, MAX) : description;","typeGuard":"function fitsMessageSize(s: string, max: number): boolean {\n  return typeof s === 'string' && s.length <= max;\n}","tryCatchPattern":"try {\n  await rest.post(url, { description });\n} catch (e) {\n  if (isMeteorError(e, 'error-message-size-exceeded')) {\n    await rest.post(url, { description: description.slice(0, MAX) });\n  } else throw e;\n}","preventionTips":["Read Message_MaxAllowedSize from public settings on client boot.","Cap description inputs in the UI with a maxlength bound to that setting.","Move long-form text into a follow-up message."],"tags":["file-upload","validation","message-size","rest-api"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}