{"record":{"id":"cc438f02e86cf0cd","repo":"RocketChat/Rocket.Chat","slug":"unable-to-get-file","errorCode":"unable-to-get-file","errorMessage":"Unable to get file","messagePattern":"Unable to get file","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts","lineNumber":44,"sourceCode":"\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\n\t\tconst account = await WebdavAccounts.findOneByIdAndUserId(accountId, userId, {});\n\t\tif (!account) {\n\t\t\tthrow new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', {\n\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst cred = getWebdavCredentials(account);\n\t\t\tconst client = new WebdavClientAdapter(account.serverURL, cred);\n\t\t\tconst fileContent = await client.getFileContents(file.filename);\n\t\t\tconst data = new Uint8Array(fileContent);\n\t\t\treturn { success: true, data };\n\t\t} catch (error) {\n\t\t\tthrow new Meteor.Error('unable-to-get-file', 'Unable to get file', {\n\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\t},\n});\n","sourceCodeStart":26,"sourceCodeEnd":50,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts#L26-L50","documentation":"Catch-all around the actual file transfer in getFileFromWebdav: building credentials from the account, constructing the WebDAV client, and client.getFileContents(file.filename). Any failure is rethrown as unable-to-get-file, so a missing file, a permissions change on the WebDAV server, expired stored credentials, or a mid-transfer network error all surface identically. The original exception is not attached, so diagnosis must happen on the WebDAV server side.","triggerScenarios":"Requesting a file whose filename no longer exists or is not readable by the account's credentials; the stored OAuth token/password expired since the account was linked; connectivity or TLS failure between Rocket.Chat and the WebDAV server during the fetch.","commonSituations":"Files renamed or deleted on the WebDAV server after the file list was cached in the picker; token-based accounts whose access token expired; flaky links or proxies interrupting large downloads.","solutions":["Re-list the directory (getWebdavFileList) and confirm file.filename still exists, then retry with the fresh value","Re-authenticate the WebDAV account (remove and re-add it) if stored credentials or the OAuth token may have expired","Check the WebDAV server's logs for the rejected request (404 vs 401 vs 502 tells you which case it is)","For recurring transient failures, wrap the download in a single retry with backoff"],"exampleFix":"// before\nawait call('getFileFromWebdav', accountId, file); // → unable-to-get-file\n\n// after — confirm the node still exists, then fetch\nconst list = await call('getWebdavFileList', accountId, dirname(file.filename));\nif (!list.data.some((n) => n.filename === file.filename)) {\n  throw new Error('File no longer exists on the WebDAV server');\n}\nawait call('getFileFromWebdav', accountId, file);","handlingStrategy":"try-catch","validationCode":"const list = await Meteor.callAsync('getWebdavFileList', accountId, dirname(file.filename));\nif (!list.data.some((n) => n.filename === file.filename)) {\n  throw new Error('File no longer exists on the WebDAV server');\n}\nawait Meteor.callAsync('getFileFromWebdav', accountId, file);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('getFileFromWebdav', accountId, file);\n} catch (e) {\n  if (e.error === 'unable-to-get-file') {\n    // re-list the directory; if the file exists, re-auth the account;\n    // one bounded retry helps only for transient network drops\n  }\n}","preventionTips":["Use filenames taken from a fresh getWebdavFileList result, not cached state","Re-link WebDAV accounts when their credentials or tokens rotate","Check the WebDAV server logs to distinguish 404/401/network cases"],"tags":["webdav","file-download","network","error-masking"],"backgroundTag":"file-download-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}