{"record":{"id":"9136afeacc8ed019","repo":"Mintplex-Labs/anything-llm","slug":"could-not-fetch-local-files","errorCode":null,"errorMessage":"Could not fetch local files.","messagePattern":"Could not fetch local files\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/models/system.js","lineNumber":89,"sourceCode":"   * Without a folderName, returns the folder shells for the picker.\n   * With one, returns that folder's documents.\n   * @param {string|null} folderName\n   * @param {number} offset\n   * @param {number|\"all\"} limit - \"all\" opts out of paging entirely; the\n   * server otherwise clamps this to its own maximum page size.\n   */\n  localFiles: async function (folderName = null, offset = 0, limit = 100) {\n    const params = new URLSearchParams();\n    if (folderName) {\n      params.set(\"folder\", folderName);\n      params.set(\"offset\", String(offset));\n      params.set(\"limit\", String(limit));\n    }\n    const qs = params.toString();\n    const url = `${API_BASE}/system/local-files${qs ? `?${qs}` : \"\"}`;\n    return await fetch(url, { headers: baseHeaders() })\n      .then((res) => {\n        if (!res.ok) throw new Error(\"Could not fetch local files.\");\n        return res.json();\n      })\n      .then((res) => (folderName ? res : res.localFiles))\n      .catch(() => null);\n  },\n  searchLocalFiles: async function (query = \"\") {\n    return await fetch(\n      `${API_BASE}/system/local-files/search?q=${encodeURIComponent(query)}`,\n      { headers: baseHeaders() }\n    )\n      .then((res) => {\n        if (!res.ok) throw new Error(\"Search failed.\");\n        return res.json();\n      })\n      .then((res) => res.results)\n      .catch(() => []);\n  },\n  getDocumentsByDocPaths: async function (docpaths = []) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/system.js#L71-L107","documentation":"Thrown by System.localFiles on a non-2xx GET to /api/system/local-files, optionally with ?folder=&offset=&limit=. Without a folderName it returns the folder shells for the picker; with one it returns that folder's documents. The .catch() returns null, so a server error collapses both branches to null.","triggerScenarios":"Calling localFiles() or localFiles(\"custom-documents\", 0, 100) when the document storage path is unreadable by the server process (500), when the folder does not exist, or when the auth token is invalid (401/403).","commonSituations":"The storage/documents directory was chmod-restricted or mounted read-only; a Docker volume was not attached; a folder name with special chars is passed that the server rejects.","solutions":["Verify the server's documents storage directory exists and is readable by the node process.","Confirm the folderName (if given) matches a folder from the no-arg listing call.","Check the auth token in localStorage is present (baseHeaders() is sent).","Read the response body in DevTools Network for the server-side error message."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function validLocalFilesArgs(folderName, offset, limit) {\n  if (folderName != null && typeof folderName !== \"string\") return false;\n  if (!Number.isInteger(offset) || offset < 0) return false;\n  if (!(limit === \"all\" || (Number.isInteger(limit) && limit > 0))) return false;\n  return true;\n}","typeGuard":"/** @param {any} r @returns {r is Array|Object} */\nfunction isLocalFilesResult(r) { return r != null && (Array.isArray(r) || typeof r === \"object\"); }","tryCatchPattern":"const res = await System.localFiles(folder, offset, limit);\nif (!isLocalFilesResult(res)) { setError(\"Documents unavailable\"); return; }","preventionTips":["Coerce offset/limit to integers before calling.","Confirm the folder name comes from a prior no-arg listing.","Null-check the result before rendering."],"tags":["network","filesystem","documents","auth"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}