RocketChat/Rocket.Chat · error · Meteor.Error
duplicated-account
duplicated-account
Error message
Account not found
What it means
Thrown when WebdavAccounts.findOneByUserIdServerUrlAndUsername finds an existing account with the same userId, serverURL, and username. Note the confusing mismatch: the error code is 'duplicated-account' but the human message reads 'Account not found' — the actual condition is the opposite, a duplicate. Client code must branch on the code, not the message.
Source
Thrown at apps/meteor/server/bridges/webdav/methods/addWebdavAccount.ts:110
}
check(
formData,
Match.ObjectIncluding({
serverURL: String,
username: String,
password: String,
name: Match.Maybe(String),
}),
);
const duplicateAccount = await WebdavAccounts.findOneByUserIdServerUrlAndUsername(
{ userId, serverURL: formData.serverURL, username: formData.username },
{},
);
if (duplicateAccount !== null) {
throw new Meteor.Error('duplicated-account', 'Account not found', {
method: 'addWebdavAccount',
});
}
try {
const client = new WebdavClientAdapter(formData.serverURL, {
username: formData.username,
password: formData.password,
});
const accountData = {
userId,
serverURL: formData.serverURL,
username: formData.username,
password: formData.password,
name: formData.name ?? '',
};
View on GitHub (pinned to b2c16d5842)
Solutions
- Remove the existing account first (Account settings / WebDAV accounts list), then re-add it
- Change the username or serverURL if you genuinely need a second account on the same server
- Match on err.error === 'duplicated-account', not the misleading 'Account not found' message
- Pre-check the accounts list in the UI before enabling submit
Example fix
// before
await call('addWebdavAccount', formData); // throws duplicated-account ('Account not found')
// after — dedupe in the UI first
const dup = accounts.some((a) => a.serverURL === formData.serverURL && a.username === formData.username);
if (dup) { showToast('Account already connected'); return; }
await call('addWebdavAccount', formData); Defensive patterns
Strategy: validation
Validate before calling
const dup = accounts.some(
(a) => a.serverURL === formData.serverURL && a.username === formData.username,
);
if (dup) {
showToast('This WebDAV account is already connected');
return;
}
await call('addWebdavAccount', formData); Try / catch
try {
await Meteor.callAsync('addWebdavAccount', formData);
} catch (e) {
if (e.error === 'duplicated-account') {
// note: the message misleadingly says 'Account not found';
// offer to remove the existing account and re-add
}
} Prevention
- Branch on the error code 'duplicated-account', never on its message
- Dedupe serverURL+username in the form before submit
- Disable double-submits while the method call is in flight
When it happens
Trigger: Submitting the addWebdavAccount form with the same serverURL + username combination the user already saved (for example, re-submitting the form after a partial success, or adding the same box twice).
Common situations: Users double-submitting the account form; retrying after a confusing first error and hitting the duplicate guard; UI not surfacing already-connected accounts, so the user re-adds an existing one.
Related errors
- error-invalid-account
- error-duplicate-role-names-not-allowed
- error-duplicated-sla
- error-business-hour-name-already-in-use
- error-token-already-exists
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/f1f695e03773d9e5.
Report an issue: GitHub.