RocketChat/Rocket.Chat · error · MeteorError
error-invalid-user
error-invalid-user
Error message
Invalid User
What it means
First guard in the uploadFileToWebdav Meteor method: Meteor.userId() was falsy on the calling connection, so there is no authenticated user to own the upload. Thrown before the Webdav_Integration_Enabled check or any file handling (including the ArrayBuffer-to-Buffer conversion) runs.
Source
Thrown at apps/meteor/server/bridges/webdav/methods/uploadFileToWebdav.ts:27
import { uploadFileToWebdav } from '../lib/uploadFileToWebdav';
const logger = new Logger('WebDAV_Upload');
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
uploadFileToWebdav(
accountId: IWebdavAccount['_id'],
fileData: string | Buffer | ArrayBuffer,
name: string,
): { success: boolean; message?: TranslationKey };
}
}
Meteor.methods<ServerMethods>({
async uploadFileToWebdav(accountId, fileData, name) {
if (!Meteor.userId()) {
throw new MeteorError('error-invalid-user', 'Invalid User', {
method: 'uploadFileToWebdav',
});
}
if (!settings.get('Webdav_Integration_Enabled')) {
throw new MeteorError('error-not-allowed', 'WebDAV Integration Not Allowed', {
method: 'uploadFileToWebdav',
});
}
try {
await uploadFileToWebdav(accountId, fileData instanceof ArrayBuffer ? Buffer.from(fileData) : fileData, name);
return { success: true };
} catch (err: any) {
if (typeof err === 'object' && err instanceof Error && err.name === 'error-invalid-account') {
throw new MeteorError(err.name, 'Invalid WebDAV Account', {
method: 'uploadFileToWebdav',
});View on GitHub (pinned to b2c16d5842)
Solutions
- Log in and confirm Meteor.userId() is set before initiating the upload
- Retry after re-authentication
- For server-side flows, call the internal uploadFileToWebdav helper directly with the target account and a Buffer
Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
throw new Error('login required before upload');
}
await Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name); Try / catch
try {
await Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name);
} catch (e: any) {
if (e?.error === 'error-invalid-user') {
// re-authenticate and let the user retry the upload
}
} Prevention
- Disable upload buttons when Meteor.user() is null
- For automated flows, ensure a valid resume token exists before starting file transfers
When it happens
Trigger: Uploading from a logged-out session; login token expired between opening the dialog and clicking upload; server-side invocation without a user context.
Common situations: Session expired in a long-open tab; automated scripts calling the method without a resume token; tests that forget to log in first.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/8ed166e6238cd0e8.
Report an issue: GitHub.