RocketChat/Rocket.Chat · error · Meteor.Error

error-importer-not-defined

error-importer-not-defined

Error message

The importer (${importerKey}) has no import class defined.

What it means

uploadImportFile receives the importerKey as a client-supplied argument and immediately looks it up via `Importers.get(importerKey)`; an unknown key throws error-importer-not-defined before any file is stored. Unlike the findLastImport-based methods, this one fails on the key YOU passed, not on stored data.

Source

Thrown at apps/meteor/server/meteor-methods/import/uploadImportFile.ts:22

import { Meteor } from 'meteor/meteor';

import { ProgressStep } from '../../../app/importer/lib/ImporterProgressStep';
import { hasPermissionAsync } from '../../lib/authorization/hasPermission';
import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';
import { Importers } from '../../lib/import';
import { RocketChatImportFileInstance } from '../../lib/import/startup/store';
import { RocketChatFile } from '../../lib/media/file';

export const executeUploadImportFile = async (
	userId: IUser['_id'],
	binaryContent: string,
	contentType: string,
	fileName: string,
	importerKey: string,
): Promise<void> => {
	const importer = Importers.get(importerKey);
	if (!importer) {
		throw new Meteor.Error('error-importer-not-defined', `The importer (${importerKey}) has no import class defined.`, 'uploadImportFile');
	}

	const operation = await Import.newOperation(userId, importer.name, importer.key);

	const instance = new importer.importer(importer, operation); // eslint-disable-line new-cap

	const date = new Date();
	const dateStr = `${date.getUTCFullYear()}${date.getUTCMonth()}${date.getUTCDate()}${date.getUTCHours()}${date.getUTCMinutes()}${date.getUTCSeconds()}`;
	const newFileName = `${dateStr}_${userId}_${fileName}`;

	// Store the file name and content type on the imports collection
	await instance.startFileUpload(newFileName, contentType);

	// Save the file on the File Store
	const file = Buffer.from(binaryContent, 'base64');
	const readStream = RocketChatFile.bufferToStream(file);
	const writeStream = RocketChatImportFileInstance.createWriteStream(newFileName, contentType);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Use an exact registered key: 'csv', 'slack', or 'slack-users' (keys are case-sensitive)
  2. Populate the importer selector from the server's importer list rather than a hardcoded array
  3. Check registration server-side if unsure: `Importers.get(key)` in a debug shell

Example fix

// before
Meteor.call('uploadImportFile', bin, 'text/csv', 'users.csv', 'CSV'); // error-importer-not-defined

// after
Meteor.call('uploadImportFile', bin, 'text/csv', 'users.csv', 'csv');
Defensive patterns

Strategy: validation

Validate before calling

const REGISTERED = ['csv', 'slack', 'slack-users'] as const;
if (!REGISTERED.includes(importerKey as (typeof REGISTERED)[number])) {
  throw new Error(`Unknown importer key '${importerKey}'; expected one of ${REGISTERED.join(', ')}`);
}
Meteor.call('uploadImportFile', binaryContent, contentType, fileName, importerKey);

Type guard

const REGISTERED_IMPORTERS = ['csv', 'slack', 'slack-users'] as const;
type ImporterKey = (typeof REGISTERED_IMPORTERS)[number];
const isImporterKey = (k: string): k is ImporterKey =>
  (REGISTERED_IMPORTERS as readonly string[]).includes(k);

Try / catch

Meteor.call('uploadImportFile', bin, type, name, key, (err) => {
  if (err && (err as Meteor.Error).error === 'error-importer-not-defined') {
    // the key YOU sent is not registered — fix the key, don't retry blindly
  }
});

Prevention

When it happens

Trigger: Calling `Meteor.call('uploadImportFile', binaryContent, contentType, fileName, importerKey)` with a key not registered on the server — typo ('Slack', 'slackusers'), a key from outdated docs, or an importer this build does not ship (valid public keys: 'csv', 'slack', 'slack-users').

Common situations: Hardcoded importer keys drifting from the server's registry; UI selector populated from a stale list; docs/blog examples naming importers removed in newer versions.

Related errors


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