{"record":{"id":"4f21d14092747ad7","repo":"RocketChat/Rocket.Chat","slug":"could-not-access-webdav","errorCode":"could-not-access-webdav","errorMessage":"Could not access webdav","messagePattern":"Could not access webdav","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/addWebdavAccount.ts","lineNumber":72,"sourceCode":"\t\tawait WebdavAccounts.updateOne(\n\t\t\t{\n\t\t\t\tuserId,\n\t\t\t\tserverURL: data.serverURL,\n\t\t\t\tname: data.name ?? '',\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: accountData,\n\t\t\t},\n\t\t\t{\n\t\t\t\tupsert: true,\n\t\t\t},\n\t\t);\n\t\tvoid api.broadcast('notify.webdav', userId, {\n\t\t\ttype: 'changed',\n\t\t\taccount: accountData,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Meteor.Error('could-not-access-webdav', 'Could not access webdav', {\n\t\t\tmethod: 'addWebdavAccount',\n\t\t});\n\t}\n\n\treturn true;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync addWebdavAccount(formData) {\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'addWebdavAccount' });\n\t\t}\n\n\t\tif (!settings.get('Webdav_Integration_Enabled')) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', {\n\t\t\t\tmethod: 'addWebdavAccount',","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/addWebdavAccount.ts#L54-L90","documentation":"This is a catch-all around the token-based WebDAV account flow: constructing/authenticating the WebDAV client with the OAuth token, upserting the account into WebdavAccounts, and broadcasting the change. Any failure inside that try block is swallowed and rethrown as the generic could-not-access-webdav Meteor.Error, so the real cause (unreachable serverURL, expired/invalid access token, TLS failure, or even a DB write error) is not visible to the client.","triggerScenarios":"Calling addWebdavAccountByToken with a serverURL that is not a reachable WebDAV endpoint; an OAuth access token that is expired or was issued for a different user/scope; network or proxy blocking WebDAV verbs; a database failure during the upsert.","commonSituations":"OAuth token expired between authorization and account save; serverURL typo or pointing at a plain HTTPS page instead of a WebDAV endpoint; corporate proxies stripping PROPFIND/OPTIONS; self-signed certificates rejected by the server-side client.","solutions":["Verify the endpoint is live WebDAV before saving: curl -X OPTIONS <serverURL> (expect 2xx and WebDAV headers)","Re-run the OAuth authorization to get a fresh access token, then retry the save","Check the Rocket.Chat server logs/stderr — the original exception is swallowed by this catch and only visible server-side","Confirm proxies/firewalls allow the WebDAV verbs (OPTIONS, PROPFIND) from the Rocket.Chat host"],"exampleFix":"// before — save directly, generic error on failure\nawait call('addWebdavAccountByToken', data); // → could-not-access-webdav\n\n// after — pre-flight the server, then save\nconst probe = await fetch(data.serverURL, { method: 'OPTIONS' });\nif (!probe.ok) throw new Error(`WebDAV server unreachable (HTTP ${probe.status})`);\nawait call('addWebdavAccountByToken', data);","handlingStrategy":"try-catch","validationCode":"// pre-flight the WebDAV endpoint before saving the account\nconst probe = await fetch(data.serverURL, { method: 'OPTIONS' });\nif (!probe.ok) throw new Error(`WebDAV server not reachable (HTTP ${probe.status})`);\nawait call('addWebdavAccountByToken', data);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('addWebdavAccountByToken', data);\n} catch (e) {\n  if (e.error === 'could-not-access-webdav') {\n    // original cause is swallowed server-side: check serverURL reachability,\n    // refresh the OAuth token, and inspect Rocket.Chat server logs\n  }\n}","preventionTips":["Probe the serverURL with an OPTIONS/PROPFIND request before submitting","Refresh OAuth tokens before they expire instead of reusing stored ones","Keep server-side logging around the helper so the swallowed exception is recorded"],"tags":["webdav","network","oauth","meteor","error-masking"],"backgroundTag":"webdav-connection-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}