{"record":{"id":"4b820b5182bcc157","repo":"thedotmack/claude-mem","slug":"failed-to-clear-logs-response-statustext","errorCode":null,"errorMessage":"Failed to clear logs: ${response.statusText}","messagePattern":"Failed to clear logs: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/ui/viewer/components/LogsModal.tsx","lineNumber":148,"sourceCode":"    } finally {\n      setIsLoading(false);\n    }\n  }, [checkIfAtBottom]);\n\n  useEffect(() => {\n    scrollToBottom();\n  }, [logs, scrollToBottom]);\n\n  const handleClearLogs = useCallback(async () => {\n    if (!confirm('Are you sure you want to clear all logs?')) {\n      return;\n    }\n    setIsLoading(true);\n    setError(null);\n    try {\n      const response = await fetch('/api/logs/clear', { method: 'POST' });\n      if (!response.ok) {\n        throw new Error(`Failed to clear logs: ${response.statusText}`);\n      }\n      setLogs('');\n    } catch (err) {\n      setError(err instanceof Error ? err.message : 'Unknown error');\n    } finally {\n      setIsLoading(false);\n    }\n  }, []);\n\n  const handleMouseDown = useCallback((e: React.MouseEvent) => {\n    e.preventDefault();\n    setIsResizing(true);\n    startYRef.current = e.clientY;\n    startHeightRef.current = height;\n  }, [height]);\n\n  useEffect(() => {\n    if (!isResizing) return;","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/ui/viewer/components/LogsModal.tsx#L130-L166","documentation":"LogsDrawer clears logs by POSTing to /api/logs/clear. If that response is not ok, it throws an Error with response.statusText, surfaced in the drawer's error state. It means the server refused or failed to truncate the log store.","triggerScenarios":"POST /api/logs/clear returns non-ok: server error while deleting/truncating the log file, endpoint missing (404), or write permissions denied on the log file.","commonSituations":"Log file owned by another user/process or read-only mount; viewer running without the clear route (older backend behind newer UI); disk-full conditions during truncation.","solutions":["POST to /api/logs/clear manually (curl -X POST) and read the status/body to see the server reason","Check filesystem write permissions on the log file and free disk space","Confirm backend version matches the UI (route exists)","After clearing fails, retry; transient file locks may resolve on a second attempt"],"exampleFix":"// before\nconst response = await fetch('/api/logs/clear', { method: 'POST' });\nif (!response.ok) {\n  throw new Error(`Failed to clear logs: ${response.statusText}`);\n}\n// after\nconst response = await fetch('/api/logs/clear', { method: 'POST' });\nif (!response.ok) {\n  const body = await response.text();\n  throw new Error(`Failed to clear logs: ${response.status} ${body}`);\n}\nsetLogs('');","handlingStrategy":"try-catch","validationCode":"const res = await fetch('/api/logs/clear', { method: 'POST' });\nif (!res.ok) throw new Error(`clear failed: ${res.status}`);","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/api/logs/clear', { method: 'POST' });\n  if (!res.ok) throw new Error(`Failed to clear logs: ${res.status} ${await res.text()}`);\n  setLogs('');\n} catch (err) {\n  showError(err instanceof Error ? err.message : 'Unknown error');\n}","preventionTips":["Ensure the server process has write access to the log file","Monitor disk space on the host running the viewer","Keep backend and UI versions in sync so the route exists","Surface the response body, not just statusText"],"tags":["network","http","ui","write"],"backgroundTag":"http-error-response","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}