RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
The getUserStatusText DDP method refuses to run because Meteor.userId() is null — the connection has no authenticated user. It only checks that some user is logged in; the target userId is passed through to getStatusText unchecked here. The method is deprecated since 9.0.0 in favor of REST /v1/users.presence.
Source
Thrown at apps/meteor/server/meteor-methods/users/getUserStatusText.ts:20
import { Meteor } from 'meteor/meteor';
import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';
import { getUsersHiddenFrom } from '../../lib/statusVisibility/hiddenUsers';
import { getStatusText } from '../../lib/users/getStatusText';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
getUserStatusText(userId: string): Promise<string | undefined>;
}
}
Meteor.methods<ServerMethods>({
async getUserStatusText(userId) {
methodDeprecationLogger.method('getUserStatusText', '9.0.0', '/v1/users.presence');
const currentUserId = Meteor.userId();
if (!currentUserId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserStatusText' });
}
const hidden = await getUsersHiddenFrom(currentUserId);
return hidden?.has(userId) ? undefined : getStatusText(userId);
},
});
View on GitHub (pinned to 2a7de45707)
Solutions
- Guard the call with Meteor.userId() and only fetch status for authenticated sessions
- Re-login on this error and retry once
- Migrate to the REST presence endpoint /v1/users.presence with an authenticated token
Example fix
// before
Meteor.callAsync('getUserStatusText', targetUserId);
// after
if (Meteor.userId()) {
await Meteor.callAsync('getUserStatusText', targetUserId);
} Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
return undefined; // anonymous views get no status text
}
return Meteor.callAsync('getUserStatusText', userId); Try / catch
try {
await Meteor.callAsync('getUserStatusText', userId);
} catch (err) {
if ((err as { error?: string }).error === 'error-invalid-user') {
// session dropped — re-authenticate and retry once
}
} Prevention
- Gate presence lookups on an authenticated session
- Do not call user-scoped methods from guest/preview render paths
- Migrate to REST /v1/users.presence (deprecation target)
When it happens
Trigger: Meteor.callAsync('getUserStatusText', userId) from an anonymous or logged-out DDP connection, or after the resume token expired mid-session.
Common situations: Status components rendered on guest/preview pages; long-open tabs with expired tokens; calls fired during a logout race.
Understand the failure class
Background: error-invalid-user: "Invalid user" errors in Rocket.Chat — what they mean and how to fix them — this error's family across 2 libraries.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@2a7de45707 (2026-08-21).
Data as JSON: /api/errors/e1a00d7928270ac5.
Report an issue: GitHub.