{"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":400,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":346,"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":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/rooms.ts#L328-L364","documentation":"Thrown by POST /api/v1/rooms.mediaConfirm/:rid/:fileId when this.bodyParams.description length exceeds the Message_MaxAllowedSize workspace setting (the message character limit). The description will become the file message's text, so it is capped like any message; a missing description passes because the check uses ?.length ?? 0.","triggerScenarios":"POST mediaConfirm with a long caption/description body parameter on a workspace where Message_MaxAllowedSize is at or below the default 5000 chars; descriptions assembled from logs or transcripts exceeding the cap.","commonSituations":"Auto-generated captions (OCR output, transcripts, log excerpts) longer than the message limit; workspaces where admins lowered Message_MaxAllowedSize but clients assumed 5000; pasting large error dumps as file descriptions.","solutions":["Truncate the description client-side before calling mediaConfirm","Or raise Message_MaxAllowedSize in Administration > General > Message (requires admin)","Move oversized text into the file itself instead of the description"],"exampleFix":"// before\nawait sdk.post(`rooms.mediaConfirm/${rid}/${fileId}`, { description: longTranscript });\n\n// after\nconst MAX = 5000; // keep in sync with Message_MaxAllowedSize\nawait sdk.post(`rooms.mediaConfirm/${rid}/${fileId}`, { description: longTranscript.slice(0, MAX) });","handlingStrategy":"validation","validationCode":"const MAX = 5000; // keep in sync with Message_MaxAllowedSize\nif ((description ?? '').length > MAX) description = description.slice(0, MAX);","typeGuard":null,"tryCatchPattern":"try {\n  await sdk.post(`rooms.mediaConfirm/${rid}/${fileId}`, { description });\n} catch (e: any) {\n  if (e?.response?.data?.errorType === 'error-message-size-exceeded') {\n    return sdk.post(`rooms.mediaConfirm/${rid}/${fileId}`, { description: description.slice(0, MAX) });\n  }\n  throw e;\n}","preventionTips":["Cap generated captions at the workspace message limit before sending","Read Message_MaxAllowedSize from server settings where available","Push oversized text into the file payload, not the description"],"tags":["rooms","file-upload","size-limit","rest-api"],"backgroundTag":"message-size-limit","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}