Mintplex-Labs/anything-llm · warning · Error
Search failed.
Error message
Search failed.
What it means
Thrown by System.searchLocalFiles on a non-2xx GET to /api/system/local-files/search?q={query}. The query is encodeURIComponent-escaped. The .catch() returns an empty array, so a failed search looks like a search with no matches.
Source
Thrown at frontend/src/models/system.js:101
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 = []) {
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(() => []);
},View on GitHub (pinned to 526360e320)
Solutions
- Run the same q via DevTools and read the status and body.
- Confirm the document index is built (System.totalIndexes returns > 0).
- Keep the query short and avoid characters that some WAFs filter even after encoding.
- Ensure baseHeaders() sends a valid token.
Defensive patterns
Strategy: validation
Validate before calling
function validQuery(q) {
return typeof q === "string" && q.trim().length > 0 && q.length <= 200;
} Type guard
/** @param {any} r @returns {r is Array} */
function isResultsArray(r) { return Array.isArray(r); } Try / catch
const results = await System.searchLocalFiles(q);
if (!isResultsArray(results)) { setResults([]); /* could not search */ } Prevention
- Trim and cap query length client-side.
- Debounce search input to avoid hammering a failing endpoint.
- Show 'no results' only when you are sure the request succeeded.
When it happens
Trigger: Calling searchLocalFiles("invoice") when the underlying search index is unavailable (500), when q is empty and the server rejects it, or when the auth token is rejected (401/403).
Common situations: Search runs before the document index finishes building; the storage path changed and the index points at a stale location; very large query strings exceed a proxy URI length limit.
Related errors
- Could not fetch local files.
- Failed to fetch documents by paths.
- 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/f1a419b58aab889c.
Report an issue: GitHub.