RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-recipient
error-invalid-recipient
Error message
error-invalid-recipient
What it means
Thrown by POST /api/v1/rooms.export with type 'email' when both toUsers and toEmails are absent or empty arrays: the export has no recipient. The check runs before dataExport.sendViaEmail, and the error carries only the code 'error-invalid-recipient' with no message. At least one username in toUsers or one address in toEmails is required.
Solutions
- Include toUsers (array of usernames) or toEmails (array of email addresses), non-empty
- Make the recipient field mandatory in the client form before submit
- Default the recipient to the requesting user when none is supplied
Example fix
// before
await sdk.post('rooms.export', { rid, type: 'email', subject: 'chat log' }); // no recipients
// after
await sdk.post('rooms.export', { rid, type: 'email', toUsers: ['alice'], subject: 'chat log', messages: [] }); Defensive patterns
Strategy: validation
Validate before calling
if (!toUsers?.length && !toEmails?.length) throw new Error('provide toUsers (usernames) or toEmails (addresses)'); Try / catch
try {
await sdk.post('rooms.export', { rid, type: 'email', toUsers, toEmails, subject, messages });
} catch (e: any) {
if (e?.response?.data?.errorType === 'error-invalid-recipient') {
return sdk.post('rooms.export', { rid, type: 'email', toUsers: [requester], subject, messages });
}
throw e;
} Prevention
- Make the recipient field required in email-export forms
- Default recipients to the requesting user in API wrappers
- Validate arrays are non-empty before templating request bodies
When it happens
Trigger: POST rooms.export type 'email' with neither toUsers nor toEmails in the body; sending toUsers: [] and toEmails: []; a form where the recipient field was optional client-side but is required server-side.
Common situations: Email-export UIs letting users submit with an empty recipient box; API wrappers defaulting both fields to empty arrays; batch jobs templating the body without filling recipients.
Related errors
- error-invalid-dates
- error-action-not-allowed
- error-invalid-custom-field-value
- error-invalid-email
- error-invalid-email
AI-assisted analysis of RocketChat/Rocket.Chat@e4b8178b20 (2026-08-18).
Data as JSON: /api/errors/f7ecd60410da0161.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/rooms.ts:1058
}
void dataExport.sendFile(
{
rid,
format,
dateFrom: convertedDateFrom,
dateTo: convertedDateTo,
},
user,
);
return API.v1.success();
}
if (type === 'email') {
const { toUsers, toEmails, subject, messages } = this.bodyParams;
if ((!toUsers || toUsers.length === 0) && (!toEmails || toEmails.length === 0)) {
throw new Meteor.Error('error-invalid-recipient');
}
const result = await dataExport.sendViaEmail(
{
rid,
toUsers: (toUsers as string[]) || [],
toEmails: toEmails || [],
subject: subject || '',
messages: messages || [],
language: user.language || 'en',
},
user,
);
return API.v1.success(result);
}
return API.v1.failure();View on GitHub (pinned to e4b8178b20)