{"record":{"id":"9068ca491b546cc2","repo":"RocketChat/Rocket.Chat","slug":"error-comment-is-required","errorCode":"error-comment-is-required","errorMessage":"error-comment-is-required","messagePattern":"error-comment-is-required","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/closeRoom.ts","lineNumber":141,"sourceCode":"\tlogger.debug({ msg: 'Room was closed', roomId: newRoom._id });\n}\n\nasync function doCloseRoom(\n\tparams: CloseRoomParams,\n\tsession: ClientSession,\n): Promise<{ room: IOmnichannelRoom; closedBy: ChatCloser; removedInquiry: ILivechatInquiryRecord | null }> {\n\tconst { comment } = params;\n\tconst { room, forceClose } = params;\n\n\tlogger.debug({ msg: 'Attempting to close room', roomId: room._id, forceClose });\n\tif (!room || !isOmnichannelRoom(room) || (!forceClose && !room.open)) {\n\t\tlogger.debug({ msg: 'Room is not open', roomId: room._id });\n\t\tthrow new Error('error-room-closed');\n\t}\n\n\tconst commentRequired = settings.get('Livechat_request_comment_when_closing_conversation');\n\tif (commentRequired && !comment?.trim()) {\n\t\tthrow new Error('error-comment-is-required');\n\t}\n\n\tconst { updatedOptions: options } = await resolveChatTags(room, params.options);\n\tlogger.debug({ msg: 'Resolved chat tags for room', roomId: room._id });\n\n\tconst now = new Date();\n\tconst { _id: rid, servedBy } = room;\n\tconst serviceTimeDuration = servedBy && (now.getTime() - new Date(servedBy.ts).getTime()) / 1000;\n\n\tconst closeData: IOmnichannelRoomClosingInfo = {\n\t\tclosedAt: now,\n\t\tchatDuration: (now.getTime() - new Date(room.ts).getTime()) / 1000,\n\t\t...(serviceTimeDuration && { serviceTimeDuration }),\n\t\t...options,\n\t};\n\tlogger.debug({ msg: 'Room was closed', roomId: room._id, closedAt: closeData.closedAt, chatDuration: closeData.chatDuration });\n\n\tif (isRoomClosedByUserParams(params)) {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/closeRoom.ts#L123-L159","documentation":"doCloseRoom reads the workspace setting 'Livechat_request_comment_when_closing_conversation'; when enabled, closing an omnichannel room without a non-blank comment throws Error('error-comment-is-required'). The check uses comment?.trim(), so whitespace-only comments are rejected too.","triggerScenarios":"Closing a livechat room via UI, REST, or server flow with the setting enabled while the comment is omitted, empty, or spaces only; bulk closes that pass no comment while the setting is on.","commonSituations":"The setting was enabled after integrations were written that close rooms without comments; bulk close of all open chats with no comment parameter; custom agent clients that skip the comment field in their close payload.","solutions":["Pass a non-empty comment (e.g. a closing reason) whenever closing rooms while the setting is enabled","If comments are not required by policy, disable Livechat_request_comment_when_closing_conversation","For bulk closes, always supply a default comment such as 'Closed in bulk'"],"exampleFix":"// before - throws when the setting is enabled\nawait closeRoom({ room, user });\n\n// after\nawait closeRoom({ room, user, comment: 'Resolved - no further response needed' });","handlingStrategy":"validation","validationCode":"import { settings } from '../../../settings/server';\n\nconst commentRequired = settings.get('Livechat_request_comment_when_closing_conversation');\nif (commentRequired && !comment?.trim()) {\n  // block the close or supply a default comment before calling closeRoom\n}","typeGuard":null,"tryCatchPattern":"try {\n  await closeRoom({ room, user, comment });\n} catch (err: any) {\n  if (err?.message === 'error-comment-is-required') return promptForComment(room);\n  throw err;\n}","preventionTips":["Make the comment field mandatory in the close dialog whenever the setting is on","Bulk-close scripts should always pass a default comment","Watch for admins flipping Livechat_request_comment_when_closing_conversation; close UIs should read its state"],"tags":["omnichannel","livechat","comment","settings","validation"],"backgroundTag":"missing-required-field","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}