RocketChat/Rocket.Chat · error · MeteorError
error-invalid-account
error-invalid-account
Error message
Invalid WebDAV Account
What it means
Different from the other error-invalid-account throws: uploadFileToWebdav delegates to the server-side uploadFileToWebdav(accountId, data, name) helper, and this is the re-wrap branch — the helper threw an Error whose name is 'error-invalid-account' (its own account lookup for the user failed). The method converts it into a MeteorError with the method name attached. So the account check happened inside the helper, after the user and settings guards already passed.
Source
Thrown at apps/meteor/server/bridges/webdav/methods/uploadFileToWebdav.ts:43
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',
});
}
logger.error({ err });
if (err.response) {
const { status } = err.response;
if (status === 404) {
return { success: false, message: 'webdav-server-not-found' };
}
if (status === 401) {
return { success: false, message: 'error-invalid-account' };
}
if (status === 412) {
return { success: false, message: 'Duplicate_file_name_found' };
}
}View on GitHub (pinned to b2c16d5842)
Solutions
- Re-authorize the WebDAV account and upload again with the fresh accountId
- Validate the accountId against the user's current account list before initiating the upload
- If the account was removed on purpose, remove the upload destination from the UI
Defensive patterns
Strategy: validation
Validate before calling
const accounts = await getWebdavAccountsForUser();
if (!accounts.some((a) => a._id === accountId)) {
throw new Error('WebDAV account is no longer available; re-authorize');
}
await Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name); Try / catch
try {
const res = await Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name);
} catch (e: any) {
if (e?.error === 'error-invalid-account') {
// prompt re-authorization; note err.name check upstream means only that name maps here
} else if (res === undefined) {
// method returns { success:false, message } for 404/401 — handle those too
}
} Prevention
- Validate the destination account immediately before starting the upload, not when the dialog first opened
- Remember this method also returns soft failures (webdav-server-not-found, 401) as { success:false } — check both the throw and the return value
When it happens
Trigger: Uploading with a deleted, re-created, or cross-user accountId; the stored WebDAV account was removed between selecting the destination and completing the upload; accountId never set in the calling code.
Common situations: Stale accountId from client state after re-authorization; admin-removed accounts; state bugs where the accountId prop is optional and passed as undefined.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d551a4d648db8be0.
Report an issue: GitHub.