RocketChat/Rocket.Chat · error · Error

Users are missing required data.

Error message

Users are missing required data.

What it means

Thrown by the import service's addUsers when a user record in the batch has no usable emails or importIds (every entry falsy/empty). Each imported user must carry at least one non-empty email and one non-empty importId so the importer can dedupe and map identities later. The check runs per record, so one bad user aborts the whole batch before insertion.

Solutions

  1. Ensure every user record has at least one non-empty email and one non-empty importId
  2. Generate deterministic importIds from the source system's user ids when missing
  3. Filter or fix records before calling addUsers instead of retrying the whole batch

Example fix

// before
await service.addUsers([{ username: 'x', emails: [], importIds: [] }]);

// after
const valid = users.filter((u) => u.emails?.some(Boolean) && u.importIds?.some(Boolean));
await service.addUsers(valid);
Defensive patterns

Strategy: validation

Validate before calling

const invalid = users.filter((u) => !u.emails?.some(Boolean) || !u.importIds?.some(Boolean));
if (invalid.length) {
  throw new Error(`${invalid.length} users lack emails/importIds`);
}
await service.addUsers(users);

Type guard

function isImportableUser(u: { emails?: string[]; importIds?: string[] }): boolean {
  return Boolean(u.emails?.some(Boolean) && u.importIds?.some(Boolean));
}

Prevention

When it happens

Trigger: addUsers([{ username: 'x' }]) with emails: [] or importIds missing; source-system exports where some users have no email address; CSV/JSON mappings that drop the importId column.

Common situations: Migrating from chat systems that allow email-less accounts; hand-built import files omitting external ids; upstream data quality issues where emails are empty strings.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/db2327e6ae14b7e1. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/server/services/import/service.ts:125

			case 'canceled':
				throw new Error('The current import operation is already finished.');
		}
	}

	public async addUsers(users: Omit<IImportUser, '_id' | 'services' | 'customFields'>[]): Promise<void> {
		if (!users.length) {
			return;
		}

		const operation = await Imports.findLastImport();

		this.assertsValidStateForNewData(operation);

		const defaultRoles = getNewUserRoles();
		const userRoles = new Set<string>(defaultRoles);
		for await (const user of users) {
			if (!user.emails?.some((value) => value) || !user.importIds?.some((value) => value)) {
				throw new Error('Users are missing required data.');
			}

			if (user.roles?.length) {
				for (const roleId of user.roles) {
					userRoles.add(roleId);
				}
			}
		}

		if (userRoles.size > 0 && !(await validateRoleList([...userRoles]))) {
			throw new Error('One or more of the users have been assigned invalid roles.');
		}

		await ImportData.col.insertMany(
			users.map((data) => ({
				_id: new ObjectId().toHexString(),
				data: {
					...data,

View on GitHub (pinned to b2c16d5842)