Mintplex-Labs/anything-llm · warning · Error
Failed to fetch documents by paths.
Error message
Failed to fetch documents by paths.
What it means
Thrown by System.getDocumentsByDocPaths on a non-2xx POST to /api/system/local-files/by-docpaths with body {docpaths}. Unlike the GET listing/search routes, this is a POST batch lookup keyed by document paths. The .catch() returns an empty array, masking server errors as 'no documents found'.
Source
Thrown at frontend/src/models/system.js:114
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 = []) {
return await fetch(`${API_BASE}/system/local-files/by-docpaths`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify({ docpaths }),
})
.then((res) => {
if (!res.ok) throw new Error("Failed to fetch documents by paths.");
return res.json();
})
.then((res) => res.documents)
.catch(() => []);
},
needsAuthCheck: function () {
const lastAuthCheck = window.localStorage.getItem(AUTH_TIMESTAMP);
if (!lastAuthCheck) return true;
const expiresAtMs = Number(lastAuthCheck) + 60 * 5 * 1000; // expires in 5 minutes in ms
return Number(new Date()) > expiresAtMs;
},
checkAuth: async function (currentToken = null) {
const valid = await fetch(`${API_BASE}/system/check-token`, {
headers: baseHeaders(currentToken),
})
.then((res) => res.ok)
.catch(() => false);View on GitHub (pinned to 526360e320)
Solutions
- Trim docpaths to known-good entries from a prior localFiles listing call.
- Check the POST body size is under your proxy's max body size (e.g. client_max_body_size).
- Read the response body in DevTools for which path the server rejected.
- Confirm baseHeaders() sends a valid token.
Defensive patterns
Strategy: validation
Validate before calling
function validDocpaths(paths) {
return Array.isArray(paths) && paths.every(p => typeof p === "string" && p.length > 0) && paths.length <= 500;
} Type guard
/** @param {any} r @returns {r is Array} */
function isDocsArray(r) { return Array.isArray(r); } Try / catch
const docs = await System.getDocumentsByDocPaths(paths);
if (!isDocsArray(docs)) { /* server error — not 'no docs' */ } Prevention
- Cap the batch size to stay under proxy body limits.
- Filter out empty/non-string paths before sending.
- Do not treat an empty array result as definitive without a status check.
When it happens
Trigger: Calling getDocumentsByDocPaths(["doc-a","doc-b"]) when one or more paths do not resolve (the server may 4xx/5xx the whole batch), when docpaths is empty and the server rejects it, or when the auth token is rejected.
Common situations: Passing stale docpaths after documents were deleted/renamed; sending a very large array that exceeds a body-size limit on a reverse proxy; mixing paths from different workspaces.
Related errors
- Could not fetch local files.
- Search failed.
- Failed to sync Confluence page content. ${reason}
- Failed to sync GitHub file content. ${reason}
- Failed to sync GitLab file content. ${reason}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/01f5dbf04dd9d598.
Report an issue: GitHub.