{"record":{"id":"18bf69eed84a4032","repo":"RocketChat/Rocket.Chat","slug":"invalid-selection-data-provided-to-the-importer","errorCode":null,"errorMessage":"Invalid Selection data provided to the importer.","messagePattern":"Invalid Selection data provided to the importer\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/import/startImport.ts","lineNumber":39,"sourceCode":"\t}\n\n\tconst instance = new importer.importer(importer, operation); // eslint-disable-line new-cap\n\n\tawait instance.startImport(input, startedByUserId);\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tstartImport(params: StartImportParamsPOST): void;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync startImport({ input }: StartImportParamsPOST) {\n\t\tmethodDeprecationLogger.method('startImport', '9.0.0', '/v1/startImport');\n\t\tif (!input || typeof input !== 'object' || !isStartImportParamsPOST({ input })) {\n\t\t\tthrow new Meteor.Error(`Invalid Selection data provided to the importer.`);\n\t\t}\n\n\t\tconst userId = Meteor.userId();\n\t\t// Takes name and object with users / channels selected to import\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'startImport');\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(userId, 'run-import'))) {\n\t\t\tthrow new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', 'startImport');\n\t\t}\n\n\t\treturn executeStartImport({ input }, userId);\n\t},\n});\n","sourceCodeStart":21,"sourceCodeEnd":55,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/startImport.ts#L21-L55","documentation":"startImport validates its payload with the ajv type guard `isStartImportParamsPOST` (from @rocket.chat/rest-typings) and throws this message — with no error code — when validation fails. The accepted shape is exactly `{ input: { users?: { all?: boolean; list?: string[] }, channels?: {...}, contacts?: {...} } }`, `input` required, no additional top-level properties.","triggerScenarios":"Calling `Meteor.call('startImport', payload)` where payload omits `input`, passes extra top-level keys (additionalProperties: false), or puts wrong types inside users/channels/contacts (e.g. `list` as objects instead of string[], `all` as string).","commonSituations":"Passing the raw selection object from getImportFileData straight through instead of mapping it to the short-selection shape; hand-writing the payload and using `message_ids` or other unlisted keys; older clients sending a shape that the ajv schema later tightened.","solutions":["Send exactly `{ input: { users: { all, list }, channels: { all, list }, contacts: { all, list } } }` with booleans for `all` and string arrays for `list`","Map the full selection from getImportFileData down to IImporterShortSelection before calling","Validate client-side first with `isStartImportParamsPOST({ input })` from '@rocket.chat/rest-typings'"],"exampleFix":"// before\nMeteor.call('startImport', selectionFromGetImportFileData); // 'Invalid Selection data provided to the importer.'\n\n// after\nconst input = {\n  users: { all: false, list: selection.users.map((u) => u.user_id) },\n  channels: { all: true, list: [] },\n};\nMeteor.call('startImport', { input });","handlingStrategy":"type-guard","validationCode":"import { isStartImportParamsPOST } from '@rocket.chat/rest-typings';\n\nconst params = { input: { users: { all: false, list: ['u1'] }, channels: { all: true, list: [] } } };\nif (!isStartImportParamsPOST(params)) {\n  // inspect isStartImportParamsPOST.errors and fix payload before calling\n}\nMeteor.call('startImport', params);","typeGuard":"import { isStartImportParamsPOST } from '@rocket.chat/rest-typings';\n\nconst isStartableSelection = (v: unknown): boolean => isStartImportParamsPOST({ input: v });","tryCatchPattern":"try {\n  await meteorCall('startImport', params);\n} catch (e) {\n  if (e instanceof Meteor.Error && e.reason === 'Invalid Selection data provided to the importer.') {\n    // this error has no code — match on message; log isStartImportParamsPOST.errors\n  }\n}","preventionTips":["Always wrap the selection as { input: ... } — no extra top-level keys (additionalProperties: false)","Use only users/channels/contacts, each { all?: boolean, list?: string[] } — list entries are string ids","Run isStartImportParamsPOST client-side; it is the exact ajv guard the server uses"],"tags":["rocket-chat","import","validation","ajv","meteor-methods"],"backgroundTag":"schema-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}