RocketChat/Rocket.Chat · warning · Meteor.Error
error-no-messages
error-no-messages
Error message
No messages found
What it means
Intended to signal that im.messages.others found no messages (im.ts:821), but the check is if (!msgs) on the result of cursor.toArray() from findPaginated. toArray() always resolves to an array and empty arrays are truthy, so on a stock server this error is unreachable: a DM with zero messages returns 200 with messages: [] and total: 0. It is effectively dead code kept from an older implementation.
Solutions
- Handle 200 with messages: [] (or total: 0) as the no-messages case, not an error
- If you genuinely receive this error, suspect a customized/forked build - report it against the upstream repo
Example fix
// before (wrong assumption)
const res = await api.get('/api/v1/im.messages.others', { params: { roomId } });
if (res.error) handleEmpty(); // never happens for empty rooms
// after
const { messages, total } = await api.get('/api/v1/im.messages.others', { params: { roomId } });
if (!messages?.length) handleEmpty(); // correct empty handling Defensive patterns
Strategy: fallback
Validate before calling
const { messages, total } = await api.get('/api/v1/im.messages.others', { params: { roomId } });
const isEmpty = !Array.isArray(messages) || messages.length === 0 || total === 0;
if (isEmpty) renderEmptyState(); Prevention
- Base empty-collection handling on the response payload (messages.length / total), never on an error
- Read the endpoint's declared 200 schema rather than inferring behavior from throw sites
When it happens
Trigger: Only a driver-level failure that resolves toArray() to a falsy value could trigger it; a normal empty room or an out-of-range offset never does.
Common situations: Developers reading the throw site and writing dedicated handlers for error-no-messages; tests asserting a 400 on empty rooms that then see 200 + [] instead.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@e4b8178b20 (2026-08-18).
Data as JSON: /api/errors/73f319c8a318c4dc.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/im.ts:827
if (!room || room?.t !== 'd') {
throw new Meteor.Error('error-room-not-found', `No direct message room found by the id of: ${roomId}`);
}
const { offset, count } = await getPaginationItems(this.queryParams);
const { sort, fields, query } = await this.parseJsonQuery();
const ourQuery = Object.assign({}, query, { rid: room._id });
const { cursor, totalCount } = Messages.findPaginated<IMessage>(ourQuery, {
sort: sort || { ts: -1 },
skip: offset,
limit: count,
projection: fields,
});
const [msgs, total] = await Promise.all([cursor.toArray(), totalCount]);
if (!msgs) {
throw new Meteor.Error('error-no-messages', 'No messages found');
}
return API.v1.success({
messages: await normalizeMessagesForUser(msgs, this.userId),
offset,
count: msgs.length,
total,
});
};
const dmListEndpointsProps = {
authRequired: true as const,
response: {
200: paginatedImsResponseSchema,
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
};View on GitHub (pinned to e4b8178b20)