{"record":{"id":"f1a419b58aab889c","repo":"Mintplex-Labs/anything-llm","slug":"search-failed","errorCode":null,"errorMessage":"Search failed.","messagePattern":"Search failed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/models/system.js","lineNumber":101,"sourceCode":"      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 = []) {\n    return await fetch(`${API_BASE}/system/local-files/by-docpaths`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify({ docpaths }),\n    })\n      .then((res) => {\n        if (!res.ok) throw new Error(\"Failed to fetch documents by paths.\");\n        return res.json();\n      })\n      .then((res) => res.documents)\n      .catch(() => []);\n  },","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/system.js#L83-L119","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function validQuery(q) {\n  return typeof q === \"string\" && q.trim().length > 0 && q.length <= 200;\n}","typeGuard":"/** @param {any} r @returns {r is Array} */\nfunction isResultsArray(r) { return Array.isArray(r); }","tryCatchPattern":"const results = await System.searchLocalFiles(q);\nif (!isResultsArray(results)) { setResults([]); /* could not search */ }","preventionTips":["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."],"tags":["network","search","documents","auth"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}