RocketChat/Rocket.Chat · error · Meteor.Error

error-importer-not-defined

error-importer-not-defined

Error message

The Pending File Importer was not found.

What it means

POST /api/v1/downloadPendingFiles requires the internal importer registered under the key 'pending-files'. That registration is unconditional at server startup: apps/meteor/server/importPackages.ts imports ./lib/import/pending-files which calls Importers.add({key: 'pending-files', ...}). error-importer-not-defined (import.ts:217) therefore means the registry lookup returned undefined - effectively impossible on a stock build; it indicates a deployment where that module never loaded (trimmed custom image, partial startup, or a fork that rewired importer registration).

Solutions

  1. Restart the server and confirm the module loads - registration has no conditions, so a healthy stock build always registers it
  2. On custom builds, verify apps/meteor/server/importPackages.ts still imports ./lib/import/pending-files and nothing filters Importers.add
  3. Compare behavior against an unmodified build; if it works there, the deployment trimmed or replaced the module
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await api.post('/api/v1/downloadPendingFiles', { ... });
} catch (err) {
  if (err.response?.body?.error === 'error-importer-not-defined') {
    // deployment-level defect on stock builds - report to the operator, do not retry
    throw new Error('pending-files importer not registered: custom build or broken startup - verify importPackages.ts');
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling POST /api/v1/downloadPendingFiles (requires run-import permission) on a custom build that prunes server modules or skips importPackages.ts; a monkey-patched Importers registry; startup errors that aborted module loading.

Common situations: Custom Docker images stripping 'unused' server code; test harnesses that import API routes without the import packages; forks that replaced the importer subsystem.

Related errors


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

Appendix: source

Thrown at apps/meteor/server/api/v1/import.ts:217

);

API.v1.post(
	'downloadPendingFiles',
	{
		authRequired: true,
		permissionsRequired: ['run-import'],
		body: isDownloadPendingFilesParamsPOST,
		response: {
			200: countResponseSchema,
			400: validateBadRequestErrorResponse,
			401: validateUnauthorizedErrorResponse,
			403: validateForbiddenErrorResponse,
		},
	},
	async function action() {
		const importer = Importers.get('pending-files');
		if (!importer) {
			throw new Meteor.Error('error-importer-not-defined', 'The Pending File Importer was not found.', 'downloadPendingFiles');
		}

		const operation = await Import.newOperation(this.userId, importer.name, importer.key);
		const instance = new PendingFileImporter(importer, operation);
		const count = await instance.prepareFileCount();

		return API.v1.success({
			count,
		});
	},
);

API.v1.post(
	'downloadPendingAvatars',
	{
		authRequired: true,
		permissionsRequired: ['run-import'],
		body: isDownloadPendingAvatarsParamsPOST,

View on GitHub (pinned to b2c16d5842)