{"record":{"id":"32d7b8f37a59adcc","repo":"thedotmack/claude-mem","slug":"failed-to-search-searchresponse-status-searc","errorCode":null,"errorMessage":"Failed to search: ${searchResponse.status} ${searchResponse.statusText}","messagePattern":"Failed to search: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-memories.ts","lineNumber":67,"sourceCode":"\nexport async function exportMemories(query: string, outputFile: string, project?: string) {\n  const settings = SettingsDefaultsManager.loadFromFile(join(resolveDataDir(), 'settings.json'));\n  const port = parseWorkerPort(settings.CLAUDE_MEM_WORKER_PORT);\n  const baseUrl = `http://localhost:${port}`;\n\n  console.log(`🔍 Searching for: \"${query}\"${project ? ` (project: ${project})` : ' (all projects)'}`);\n\n  const params = new URLSearchParams({\n    query,\n    format: 'json',\n    limit: '999999'\n  });\n  if (project) params.set('project', project);\n\n  console.log('📡 Fetching all memories via hybrid search...');\n  const searchResponse = await fetchWithTimeout(`${baseUrl}/api/search?${params.toString()}`);\n  if (!searchResponse.ok) {\n    throw new Error(`Failed to search: ${searchResponse.status} ${searchResponse.statusText}`);\n  }\n  const searchData = await searchResponse.json();\n\n  const observations: ObservationRecord[] = searchData.observations || [];\n  const summaries: SessionSummaryRecord[] = searchData.sessions || [];\n  const prompts: UserPromptRecord[] = searchData.prompts || [];\n\n  console.log(`✅ Found ${observations.length} observations`);\n  console.log(`✅ Found ${summaries.length} session summaries`);\n  console.log(`✅ Found ${prompts.length} user prompts`);\n\n  const memorySessionIds = new Set<string>();\n  observations.forEach((o) => {\n    if (o.memory_session_id) memorySessionIds.add(o.memory_session_id);\n  });\n  summaries.forEach((s) => {\n    if (s.memory_session_id) memorySessionIds.add(s.memory_session_id);\n  });","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/export-memories.ts#L49-L85","documentation":"Thrown after the GET to /api/search returns a non-2xx status. fetchWithTimeout already handled transport-level failures (timeouts, DNS), so reaching this branch means the worker answered but refused/errored on the search request. The message includes the status code and statusText for triage.","triggerScenarios":"The worker returns 400 (bad query params), 404 (wrong port — a different service answering, or the route is absent in this worker version), 500 (search backend crash — Postgres or Chroma), or 503 (worker not ready). Also any non-allowed code from a reverse proxy in front of the worker.","commonSituations":"CLAUDE_MEM_WORKER_PORT points at a stale/wrong process. The worker binary is an older version without /api/search. The vector/Chroma backend is misconfigured and the hybrid search path throws 500. The data dir is locked or the DB not migrated.","solutions":["Confirm the port matches the running worker (check the worker startup log) so the request reaches the right process.","Read the worker logs for the matching 4xx/5xx to find the underlying cause (DB, Chroma, migration).","If status is 404, upgrade/restart the worker so its route table matches this script's expected endpoints.","If status is 500, run the worker's DB/migration setup and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const probe = await fetchWithTimeout(`${baseUrl}/api/health`);\nif (!probe.ok) throw new Error(`Worker not healthy: ${probe.status}`);","typeGuard":null,"tryCatchPattern":"try {\n  const r = await fetchWithTimeout(`${baseUrl}/api/search?${params}`);\n  if (!r.ok) throw new Error(`search ${r.status}`);\n} catch (e) {\n  if (e instanceof Error && /Failed to search/.test(e.message)) {\n    // inspect status: 404 -> wrong port/version; 500 -> backend\n  }\n  throw e;\n}","preventionTips":["Verify the worker port and version expose /api/search before exporting.","Health-check the worker (and its DB/vector backend) before issuing large search requests.","Keep the worker and the export script from the same release so routes match."],"tags":["network","http","api","worker","export"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}