{"record":{"id":"57d6c4dcf3bf439c","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-id","errorCode":null,"errorMessage":"Invalid user id","messagePattern":"Invalid user id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/moderation.ts","lineNumber":42,"sourceCode":"\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\n\t\tif (!userId) {\n\t\t\tthrow new Error('Invalid user id');\n\t\t}\n\t\tawait ModerationReports.hideMessageReportsByUserId(userId, appId, reason, action);\n\t}\n}\n","sourceCodeStart":24,"sourceCodeEnd":47,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/moderation.ts#L24-L47","documentation":"AppModerationBridge.dismissReportsByUserId throws when userId is falsy before calling ModerationReports.hideMessageReportsByUserId. The dismissal of all reports filed by a user requires that user's id, so the bridge rejects the call early when it is missing.","triggerScenarios":"An app calls dismiss-reports-by-user with undefined/null/'' — e.g. a reporter id that was not stored with the report, an optional field on a persisted record, or a payload from a UI interaction missing the user context.","commonSituations":"Reporter information lost when persisting moderation state; handlers mixing up reporter id and message id arguments; state objects created before the reporter field was added (older persisted records).","solutions":["Persist the reporter id together with every report record you plan to dismiss by","Validate before calling: skip with a warning when !userId","Check argument order — userId is a separate parameter from messageId/reason/action","Migrate old persisted state that lacks the user id"],"exampleFix":"// before\nawait app.getRocketChat().getModeration().dismissReportsByUserId(reporter?.id, reason, action); // undefined -> throws\n// after\nif (!reporter?.id) { app.getLogger().warn('dismiss skipped: no reporter id'); return; }\nawait app.getRocketChat().getModeration().dismissReportsByUserId(reporter.id, reason, action);","handlingStrategy":"validation","validationCode":"const dismissByUser = async (userId: unknown, reason: string, action: string) => {\n  if (typeof userId !== 'string' || userId === '') {\n    app.getLogger().warn('dismiss skipped: no reporter id');\n    return;\n  }\n  await app.getRocketChat().getModeration().dismissReportsByUserId(userId, reason, action);\n};","typeGuard":"const isId = (v: unknown): v is string => typeof v === 'string' && v.length > 0;\n\nif (isId(reporter?.id)) {\n  await app.getRocketChat().getModeration().dismissReportsByUserId(reporter.id, reason, action);\n}","tryCatchPattern":"try {\n  await app.getRocketChat().getModeration().dismissReportsByUserId(userId, reason, action);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Invalid user id') {\n    app.getLogger().warn('dismiss skipped: reporter id missing');\n    return;\n  }\n  throw err;\n}","preventionTips":["Store reporter ids with report records at creation time","Validate persisted state shape after app upgrades that add new fields","Never assume optional persisted fields exist — default them on read","Guard all moderation bridge calls with one shared id-validator"],"tags":["apps-engine","moderation","dismiss","validation","missing-id"],"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"}