RocketChat/Rocket.Chat · error · Meteor.Error
error-import-operation-invalid
error-import-operation-invalid
Error message
Invalid Import Operation
What it means
Thrown by getImportFileData when the latest import operation is in one of the 'waiting' steps (DOWNLOADING_FILE, PREPARING_CHANNELS, PREPARING_MESSAGES, PREPARING_USERS, PREPARING_CONTACTS, PREPARING_STARTED) but its `importRecord.valid` flag is falsy. The method would normally return `{ waiting: true }` during preparation; an invalid record means preparation cannot be trusted to finish, so the operation is rejected as invalid.
Source
Thrown at apps/meteor/server/meteor-methods/import/getImportFileData.ts:43
throw new Meteor.Error('error-importer-not-defined', `The importer (${importerKey}) has no import class defined.`, 'getImportFileData');
}
const instance = new importer.importer(importer, operation); // eslint-disable-line new-cap
const waitingSteps: IImportProgress['step'][] = [
ProgressStep.DOWNLOADING_FILE,
ProgressStep.PREPARING_CHANNELS,
ProgressStep.PREPARING_MESSAGES,
ProgressStep.PREPARING_USERS,
ProgressStep.PREPARING_CONTACTS,
ProgressStep.PREPARING_STARTED,
];
if (waitingSteps.indexOf(instance.progress.step) >= 0) {
if (instance.importRecord?.valid) {
return { waiting: true };
}
throw new Meteor.Error('error-import-operation-invalid', 'Invalid Import Operation', 'getImportFileData');
}
const readySteps: IImportProgress['step'][] = [
ProgressStep.USER_SELECTION,
ProgressStep.DONE,
ProgressStep.CANCELLED,
ProgressStep.ERROR,
];
if (readySteps.indexOf(instance.progress.step) >= 0) {
return instance.buildSelection();
}
const fileName = instance.importRecord.file;
if (fileName) {
const fullFilePath = fs.existsSync(fileName) ? fileName : path.join(RocketChatImportFileInstance.absolutePath, fileName);
await instance.prepareUsingLocalFile(fullFilePath);
}View on GitHub (pinned to b2c16d5842)
Solutions
- Call `Meteor.call('getImportProgress')` first to see the actual step and whether the operation is stuck
- If the record is invalid, restart the flow: re-upload the file with `uploadImportFile` (this creates a new operation) instead of continuing to poll
- Verify the source export file is complete and uncorrupted (re-download the Slack export, regenerate the CSV) before uploading
- Avoid polling getImportFileData after a mid-preparation server restart; start a new import instead
Example fix
// before
Meteor.call('getImportFileData', (err, data) => { /* error-import-operation-invalid while prep 'in progress' */ });
// after — check progress, and when invalid restart the import cleanly
Meteor.call('getImportProgress', (e, progress) => {
if (progress.step === 'preparing_users' && !progress.valid) {
Meteor.call('uploadImportFile', binaryContent, 'application/zip', 'export.zip', 'slack');
}
}); Defensive patterns
Strategy: try-catch
Validate before calling
// Poll progress first; only fetch file data when the operation looks healthy
Meteor.call('getImportProgress', (e, p) => {
const WAITING = ['downloading_file', 'preparing_channels', 'preparing_messages', 'preparing_users', 'preparing_contacts', 'preparing_started'];
if (!WAITING.includes(p.step)) Meteor.call('getImportFileData', cb);
}); Try / catch
try {
const result = await meteorCall('getImportFileData');
} catch (e) {
if (e instanceof Meteor.Error && e.error === 'error-import-operation-invalid') {
// record invalid: restart the flow with a fresh uploadImportFile
}
} Prevention
- Stop polling getImportFileData after a server restart during preparation
- Validate export archives (size/checksum) before upload so importRecord.valid stays true
- Treat { waiting: true } as the only healthy mid-preparation response; anything else means restart
When it happens
Trigger: Polling `Meteor.call('getImportFileData')` while an import is mid-preparation whose upload record was marked invalid — e.g. the uploaded file failed validation, the server restarted during preparation, or the operation was interrupted between startFileUpload and the prep steps completing.
Common situations: Server crash/restart in the middle of preparing a large Slack or CSV import; uploading a truncated/corrupted export file that fails import-record validation; retrying an old import whose file entry in RocketChatImportFileInstance no longer validates.
Related errors
- error-importer-not-defined
- error-invalid-user
- error-action-not-allowed
- error-operation-not-found
- error-importer-not-defined
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/062c978805bd7c45.
Report an issue: GitHub.