RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
getImportFileData requires an authenticated DDP session; it calls `Meteor.userId()` and throws error-invalid-user when that returns null. This is the standard Rocket.Chat signal that the method was invoked without a logged-in user (no resume token, expired token, or a server-to-server call with no user context).
Source
Thrown at apps/meteor/server/meteor-methods/import/getImportFileData.ts:79
}
return instance.buildSelection();
};
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
getImportFileData(): IImporterSelection | { waiting: true };
}
}
Meteor.methods<ServerMethods>({
async getImportFileData() {
methodDeprecationLogger.method('getImportFileData', '9.0.0', '/v1/getImportFileData');
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', 'getImportFileData');
}
if (!(await hasPermissionAsync(userId, 'run-import'))) {
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', 'getImportFileData');
}
return executeGetImportFileData();
},
});
View on GitHub (pinned to b2c16d5842)
Solutions
- Log in before calling (Meteor.loginWithPassword / loginWithToken) and confirm `Meteor.userId()` is set
- Handle token expiry: on this error, re-authenticate and retry the call once
- For automation, use the REST endpoint POST /v1/getImportFileData with valid X-Auth-Token/X-User-Id headers instead of a raw DDP method call
Example fix
// before
Meteor.call('getImportFileData', cb); // error-invalid-user when logged out
// after
if (!Meteor.userId()) {
await new Promise((resolve, reject) => Meteor.loginWithToken(token, (e) => (e ? reject(e) : resolve())));
}
Meteor.call('getImportFileData', cb); Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
// login or restore the session before calling
await new Promise((res, rej) => Meteor.loginWithToken(savedToken, (e) => (e ? rej(e) : res())));
}
Meteor.call('getImportFileData', cb); Try / catch
Meteor.call('getImportFileData', (err, data) => {
if (err && (err as Meteor.Error).error === 'error-invalid-user') {
// session expired: re-login, then retry once
}
}); Prevention
- Check Meteor.userId() before any import method call
- Refresh long-lived sessions before entering the import wizard
- Prefer REST endpoints with X-User-Id/X-Auth-Token for automation
When it happens
Trigger: Invoking `Meteor.call('getImportFileData')` from an unauthenticated DDP connection, after the accounts resume token expired, or from server-side code without a user bound to the method invocation.
Common situations: Long-lived admin tabs whose login token expired; automated scripts calling Meteor methods directly without logging in first; switching to 9.x where the REST equivalents (POST /v1/getImportFileData) are preferred and the method call lost its session.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/476a95f9edc5a654.
Report an issue: GitHub.