RocketChat/Rocket.Chat · error · Error

Invalid user id

Error message

Invalid user id

What it means

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.

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 f9d3ec372b)

Solutions

  1. Look up the user first and bail if not found, then call dismiss with the resolved id.
  2. Validate the id shape (non-empty string) at the boundary of your App's action handler.
  3. Log the missing id context for debugging rather than letting the bridge throw an opaque error.

Example fix

// before
await moderation.dismissReportsByUserId(undefined, reason, action, appId);

// after
const user = await users.getById(targetUsername);
if (user?.id) {
  await moderation.dismissReportsByUserId(user.id, reason, action, appId);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!userId || typeof userId !== 'string') {
  throw new Error('A valid user id is required to dismiss reports');
}
await moderation.dismissReportsByUserId(userId, reason, action, appId);

Type guard

function isUserId(value: unknown): value is string {
  return typeof value === 'string' && value.length > 0;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/57d6c4dcf3bf439c. Report an issue: GitHub.