RocketChat/Rocket.Chat · error
Invalid user id
Error message
Invalid user id
What it means
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.
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
Example fix
// before
await app.getRocketChat().getModeration().dismissReportsByUserId(reporter?.id, reason, action); // undefined -> throws
// after
if (!reporter?.id) { app.getLogger().warn('dismiss skipped: no reporter id'); return; }
await app.getRocketChat().getModeration().dismissReportsByUserId(reporter.id, reason, action); Defensive patterns
Strategy: validation
Validate before calling
const dismissByUser = async (userId: unknown, reason: string, action: string) => {
if (typeof userId !== 'string' || userId === '') {
app.getLogger().warn('dismiss skipped: no reporter id');
return;
}
await app.getRocketChat().getModeration().dismissReportsByUserId(userId, reason, action);
}; Type guard
const isId = (v: unknown): v is string => typeof v === 'string' && v.length > 0;
if (isId(reporter?.id)) {
await app.getRocketChat().getModeration().dismissReportsByUserId(reporter.id, reason, action);
} Try / catch
try {
await app.getRocketChat().getModeration().dismissReportsByUserId(userId, reason, action);
} catch (err) {
if (err instanceof Error && err.message === 'Invalid user id') {
app.getLogger().warn('dismiss skipped: reporter id missing');
return;
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/57d6c4dcf3bf439c.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/app/apps/server/bridges/moderation.ts:42
await reportMessage(messageId, description, userId || 'rocket.cat');
}
protected async dismissReportsByMessageId(messageId: IMessage['id'], reason: string, action: string, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is dismissing reports by message id.`);
if (!messageId) {
throw new Error('Invalid message id');
}
await ModerationReports.hideMessageReportsByMessageId(messageId, appId, reason, action);
}
protected async dismissReportsByUserId(userId: IUser['id'], reason: string, action: string, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is dismissing reports by user id.`);
if (!userId) {
throw new Error('Invalid user id');
}
await ModerationReports.hideMessageReportsByUserId(userId, appId, reason, action);
}
}
View on GitHub (pinned to b2c16d5842)