RocketChat/Rocket.Chat · error · Error
error-user-not-found
Error message
error-user-not-found
What it means
Thrown as Error('error-user-not-found') in the GET push.* action when Users.findOneById(this.userId) returns null. Identical shape to the transcript user-not-found case: authRequired populated this.userId, but the user document is missing, so subsequent logic that uses the receiver cannot proceed. The next guards (message-not-found, room-not-found) are never reached.
Source
Thrown at apps/meteor/server/api/v1/push.ts:306
const pushGetInfoEndpoints = API.v1
.get(
'push.get',
{
authRequired: true,
query: isPushGetProps,
response: {
200: pushGetResponseSchema,
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
},
async function action() {
const { id } = this.queryParams;
const receiver = await Users.findOneById(this.userId);
if (!receiver) {
throw new Error('error-user-not-found');
}
const message = await Messages.findOneById(id);
if (!message) {
throw new Error('error-message-not-found');
}
const room = await Rooms.findOneById(message.rid);
if (!room) {
throw new Error('error-room-not-found');
}
if (!(await canAccessRoomAsync(room, receiver))) {
throw new Error('error-not-allowed');
}
const data = await PushNotification.getNotificationForMessageId({ receiver, room, message });
View on GitHub (pinned to f9d3ec372b)
Solutions
- Verify the X-User-Id corresponds to an existing user document.
- Force re-login on the client to obtain a token for a live user.
- Audit deletion events for the affected userId.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
const me = await fetch('/api/v1/v1/me', { headers }).then(r => r.ok ? r.json() : null);
if (!me) { /* re-login before push calls */ } Type guard
null
Try / catch
try {
await fetch('/api/v1/v1/push...' /* etc */);
} catch (e) {
if (e.error === 'error-user-not-found') { /* clear session, re-authenticate */ }
else throw e;
} Prevention
- Validate the session with /me before push operations.
- Clear cached tokens when the user is deleted.
- Treat error-user-not-found as a session-invalidation signal.
When it happens
Trigger: A push-related GET with a valid auth token whose userId was deleted from the users collection; a fixture that authenticates without inserting the user.
Common situations: User deleted after the mobile client cached its session; stale token on a restored-from-backup DB; test harness using a fabricated userId.
Related errors
- error-invalid-user
- error-authToken-param-not-valid
- error-message-not-found
- error-room-not-found
- error-invalid-user
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/6b7c07c679762993.
Report an issue: GitHub.