Mintplex-Labs/anything-llm · warning · Error
Could not fetch local files.
Error message
Could not fetch local files.
What it means
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.
Source
Thrown at frontend/src/models/system.js:89
* Without a folderName, returns the folder shells for the picker.
* With one, returns that folder's documents.
* @param {string|null} folderName
* @param {number} offset
* @param {number|"all"} limit - "all" opts out of paging entirely; the
* server otherwise clamps this to its own maximum page size.
*/
localFiles: async function (folderName = null, offset = 0, limit = 100) {
const params = new URLSearchParams();
if (folderName) {
params.set("folder", folderName);
params.set("offset", String(offset));
params.set("limit", String(limit));
}
const qs = params.toString();
const url = `${API_BASE}/system/local-files${qs ? `?${qs}` : ""}`;
return await fetch(url, { headers: baseHeaders() })
.then((res) => {
if (!res.ok) throw new Error("Could not fetch local files.");
return res.json();
})
.then((res) => (folderName ? res : res.localFiles))
.catch(() => null);
},
searchLocalFiles: async function (query = "") {
return await fetch(
`${API_BASE}/system/local-files/search?q=${encodeURIComponent(query)}`,
{ headers: baseHeaders() }
)
.then((res) => {
if (!res.ok) throw new Error("Search failed.");
return res.json();
})
.then((res) => res.results)
.catch(() => []);
},
getDocumentsByDocPaths: async function (docpaths = []) {View on GitHub (pinned to 526360e320)
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.
Defensive patterns
Strategy: validation
Validate before calling
function validLocalFilesArgs(folderName, offset, limit) {
if (folderName != null && typeof folderName !== "string") return false;
if (!Number.isInteger(offset) || offset < 0) return false;
if (!(limit === "all" || (Number.isInteger(limit) && limit > 0))) return false;
return true;
} Type guard
/** @param {any} r @returns {r is Array|Object} */
function isLocalFilesResult(r) { return r != null && (Array.isArray(r) || typeof r === "object"); } Try / catch
const res = await System.localFiles(folder, offset, limit);
if (!isLocalFilesResult(res)) { setError("Documents unavailable"); return; } Prevention
- Coerce offset/limit to integers before calling.
- Confirm the folder name comes from a prior no-arg listing.
- Null-check the result before rendering.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Failed to download file
- Search failed.
- Failed to fetch documents by paths.
- Failed to sync Confluence page content. ${reason}
- Failed to sync GitHub file content. ${reason}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/9136afeacc8ed019.
Report an issue: GitHub.