{"record":{"id":"9d2fb3bb5fdeac97","repo":"odysseus-dev/odysseus","slug":"http-res-status-9d2fb3","errorCode":null,"errorMessage":"HTTP ${res.status}","messagePattern":"HTTP \\$\\{res\\.status\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"static/js/tasks.js","lineNumber":1932,"sourceCode":"    if (!res.ok) throw new Error('Failed to revert task');\n    if (uiModule) uiModule.showToast('Reverted to default');\n    await _fetchTasks();\n    _renderMainView();\n  } catch (e) { if (uiModule) uiModule.showError(e.message); }\n}\n\nasync function _doClearTaskCache(id, label = 'cache') {\n  const ok = uiModule?.styledConfirm\n    ? await uiModule.styledConfirm(`Clear cached ${label} for this task?`, { confirmText: 'Clear' })\n    : confirm(`Clear cached ${label} for this task?`);\n  if (!ok) return;\n  try {\n    const res = await fetch(`${API_BASE}/api/tasks/${encodeURIComponent(id)}/clear-cache`, {\n      method: 'POST',\n      credentials: 'same-origin',\n    });\n    const data = await res.json().catch(() => ({}));\n    if (!res.ok || !data.ok) throw new Error(data.detail || data.error || `HTTP ${res.status}`);\n    const n = Object.values(data.cleared || {}).reduce((a, b) => a + Number(b || 0), 0) + Number(data.files || 0);\n    if (uiModule) uiModule.showToast(`Cleared ${label}${n ? ` (${n})` : ''}`);\n  } catch (e) {\n    if (uiModule) uiModule.showError(`Clear cache failed: ${e.message || e}`);\n  }\n}\n\nasync function _doToggleAll() {\n  // If any task is active → pause all. Else resume all paused tasks.\n  const hasActive = _tasks.some(t => t.status === 'active');\n  const targets = _tasks.filter(t => t.status === (hasActive ? 'active' : 'paused'));\n  if (targets.length === 0) {\n    if (uiModule) uiModule.showToast('No tasks to ' + (hasActive ? 'pause' : 'resume'));\n    return;\n  }\n  const verb = hasActive ? 'Pause' : 'Resume';\n  let confirmed = true;\n  if (uiModule?.styledConfirm) {","sourceCodeStart":1914,"sourceCodeEnd":1950,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/static/js/tasks.js#L1914-L1950","documentation":"Fallback error thrown by _doClearTaskCache when POST /api/tasks/{id}/clear-cache fails. The code prefers data.detail, then data.error, and only falls back to `HTTP {status}` when the body is neither ok nor carries either field. The catch wrapper prefixes it as 'Clear cache failed: ...' in a toast.","triggerScenarios":"Clearing a task's cache for a task id that doesn't exist (404), when the server returns 200 but data.ok is falsy without detail/error fields, when auth fails (401/403), or when the response is non-JSON (the .catch(() => ({})) yields an empty object).","commonSituations":"Task list is stale and the task was deleted server-side; proxy or gateway returns an HTML error page; session expired.","solutions":["Check the status code shown in the toast: 404 = task missing, 401/403 = re-login, 500 = server-side cache clear failure (check logs)","Refresh the task list before clearing cache if the task may have been removed","If a proxy sits in front, make sure it preserves JSON error responses for /api/tasks/*"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!_tasks.some(t => t.id === id)) { showToast('Task not found — refresh list'); return; }","typeGuard":null,"tryCatchPattern":"try { await _doClearTaskCache(id, label); } catch (e) { /* toast already shown by _doClearTaskCache */ }","preventionTips":["Treat cache-clear failures as non-fatal (cache will rebuild)","Keep the message chain detail → error → status so real causes survive","Refresh stale task lists before cache operations"],"tags":["http","frontend","tasks","cache"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}