{"record":{"id":"57d6c4dcf3bf439c","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-id","errorCode":null,"errorMessage":"Invalid user id","messagePattern":"Invalid user id","errorType":"exception","errorClass":"Error","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/moderation.ts#L24-L47","documentation":"Thrown by AppModerationBridge.dismissReportsByUserId when userId is falsy. This path hides all reports filed against messages authored by the given user via ModerationReports.hideMessageReportsByUserId. The guard prevents a broad update query from running with an undefined user filter.","triggerScenarios":"An App calls dismiss-by-user with an empty user id — typically when the target user object was looked up asynchronously and the lookup returned undefined, or when the App acts on a webhook payload whose user reference was absent.","commonSituations":"Admin tooling that resolves a user by email/username before dismissing; flows where the user has been deleted mid-session; federation users whose local id mapping is missing.","solutions":["Look up the user first and bail if not found, then call dismiss with the resolved id.","Validate the id shape (non-empty string) at the boundary of your App's action handler.","Log the missing id context for debugging rather than letting the bridge throw an opaque error."],"exampleFix":"// before\nawait moderation.dismissReportsByUserId(undefined, reason, action, appId);\n\n// after\nconst user = await users.getById(targetUsername);\nif (user?.id) {\n  await moderation.dismissReportsByUserId(user.id, reason, action, appId);\n}","handlingStrategy":"validation","validationCode":"if (!userId || typeof userId !== 'string') {\n  throw new Error('A valid user id is required to dismiss reports');\n}\nawait moderation.dismissReportsByUserId(userId, reason, action, appId);","typeGuard":"function isUserId(value: unknown): value is string {\n  return typeof value === 'string' && value.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Resolve the target user via the users accessor before offering the dismiss-by-user action.","Handle the 'user not found' case in your App flow rather than letting the bridge throw.","Beware deleted/federated users whose local id may be missing."],"tags":["apps-engine","moderation-bridge","validation","user-id","truthy-check"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}