{"record":{"id":"ab7d13a808907f2b","repo":"RocketChat/Rocket.Chat","slug":"invalid-description","errorCode":null,"errorMessage":"Invalid description","messagePattern":"Invalid description","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/moderation.ts","lineNumber":22,"sourceCode":"import type { IUser } from '@rocket.chat/apps-engine/definition/users';\nimport { ModerationReports } from '@rocket.chat/models';\n\nimport { reportMessage } from '../../../../server/lib/moderation/reportMessage';\n\nexport class AppModerationBridge extends ModerationBridge {\n\tconstructor(private readonly orch: IAppServerOrchestrator) {\n\t\tsuper();\n\t}\n\n\tprotected async report(messageId: IMessage['id'], description: string, userId: string, appId: string): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating a new report.`);\n\n\t\tif (!messageId) {\n\t\t\tthrow new Error('Invalid message id');\n\t\t}\n\n\t\tif (!description) {\n\t\t\tthrow new Error('Invalid description');\n\t\t}\n\n\t\tawait reportMessage(messageId, description, userId || 'rocket.cat');\n\t}\n\n\tprotected async dismissReportsByMessageId(messageId: IMessage['id'], reason: string, action: string, appId: string): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is dismissing reports by message id.`);\n\n\t\tif (!messageId) {\n\t\t\tthrow new Error('Invalid message id');\n\t\t}\n\n\t\tawait ModerationReports.hideMessageReportsByMessageId(messageId, appId, reason, action);\n\t}\n\n\tprotected async dismissReportsByUserId(userId: IUser['id'], reason: string, action: string, appId: string): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is dismissing reports by user id.`);\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/moderation.ts#L4-L40","documentation":"AppModerationBridge.report throws when the description passed to the moderation report API is falsy (undefined, null, ''). Rocket.Chat requires every message report to carry a human-readable reason; unlike userId, description has no default fallback, so an empty description is rejected before reportMessage runs.","triggerScenarios":"An app reports a message without passing a description argument, passes an empty string, or passes a variable that resolves to undefined (optional config, empty form field).","commonSituations":"Apps reporting from automated hooks (e.g. onPostMessage) with no reason text wired in; UI modals where the reason textarea was left blank and the value was not validated.","solutions":["Always pass a non-empty description, even for automated reports (e.g. 'Flagged automatically by app X')","Trim and check before calling: if (!description?.trim()) return","Require and validate the reason field in any app UI before submitting"],"exampleFix":"// before\nawait app.getRocketChat().getModeration().reportMessage(messageId, reasonFromForm, userId); // blank form -> throws\n// after\nconst description = reasonFromForm?.trim() || `Flagged by app ${app.getID()}`;\nawait app.getRocketChat().getModeration().reportMessage(messageId, description, userId);","handlingStrategy":"validation","validationCode":"const description = (reasonFromForm ?? '').trim() || `Flagged automatically by app ${app.getID()}`;\nawait app.getRocketChat().getModeration().reportMessage(messageId, description, userId);","typeGuard":"const isNonEmptyDescription = (d: unknown): d is string =>\n  typeof d === 'string' && d.trim().length > 0;\n\nif (!isNonEmptyDescription(reason)) { /* prompt user or bail */ }","tryCatchPattern":"try {\n  await app.getRocketChat().getModeration().reportMessage(messageId, description, userId);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Invalid description') {\n    app.getLogger().warn('report skipped: empty description');\n    return;\n  }\n  throw err;\n}","preventionTips":["Mark the description as required in any reporting UI and validate before submit","Default automated reports to a generated reason string","Trim input; whitespace-only strings are falsy-adjacent and useless as reports","Keep report fields together in one typed payload object"],"tags":["apps-engine","moderation","report","validation","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}