{"record":{"id":"ddd0b24c6aeb5ebd","repo":"odysseus-dev/odysseus","slug":"failed-to-revert-task","errorCode":null,"errorMessage":"Failed to revert task","messagePattern":"Failed to revert task","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"static/js/tasks.js","lineNumber":1914,"sourceCode":"    : confirm('Delete this task and all its run history?');\n  if (!ok) return;\n  try {\n    await _deleteTask(id);\n    await _animateTaskRemoval([id]);\n    if (uiModule) uiModule.showToast('Task deleted');\n    await _fetchTasks();\n    _renderMainView();\n  } catch (e) { if (uiModule) uiModule.showError(e.message); }\n}\n\nasync function _doRevert(id) {\n  const ok = uiModule?.styledConfirm\n    ? await uiModule.styledConfirm('Revert this built-in task to its default schedule and settings?', { confirmText: 'Revert' })\n    : confirm('Revert this built-in task to its default?');\n  if (!ok) return;\n  try {\n    const res = await fetch(`${API_BASE}/api/tasks/${id}/revert`, { method: 'POST', credentials: 'same-origin' });\n    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}`);","sourceCodeStart":1896,"sourceCodeEnd":1932,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/static/js/tasks.js#L1896-L1932","documentation":"Thrown when POST /api/tasks/{id}/revert (revert a built-in task to defaults) returns a non-2xx status. Unlike other calls in this module it does not parse the response body at all, so the backend's actual reason is always discarded and shown to the user as the generic message via showError.","triggerScenarios":"Clicking Revert (after confirming) on a task that is not a built-in/customized task (404/400), on a task whose defaults cannot be restored server-side (500), or with an expired session (401/403).","commonSituations":"Revert offered in the UI for tasks that have no default definition on the server; server task definitions updated between page load and revert; auth cookie expired.","solutions":["Check the network tab for the real status code of the /revert call — the UI message hides it","Only show the Revert action for tasks flagged as built-in/customized in GET /api/tasks","Refresh the task list and retry; re-login on 401/403","Improve the handler to parse res.json() detail like _doClearTaskCache does"],"exampleFix":"// before\nconst res = await fetch(`${API_BASE}/api/tasks/${id}/revert`, { method: 'POST', credentials: 'same-origin' });\nif (!res.ok) throw new Error('Failed to revert task');\n// after\nconst res = await fetch(`${API_BASE}/api/tasks/${id}/revert`, { method: 'POST', credentials: 'same-origin' });\nconst data = await res.json().catch(() => ({}));\nif (!res.ok) throw new Error(data.detail || `Failed to revert task (${res.status})`);","handlingStrategy":"try-catch","validationCode":"const t = _tasks.find(x => x.id === id);\nif (!t || !t.is_builtin && !t.customized) { showToast('Nothing to revert'); return; }","typeGuard":null,"tryCatchPattern":"try { await _doRevert(id); } catch (e) { uiModule?.showError(e.message || 'Revert failed'); await _fetchTasks(); }","preventionTips":["Gate the Revert action on the task actually being a customized built-in","Parse response detail instead of throwing generic messages","Refresh task state after failures"],"tags":["http","frontend","tasks","error-handling"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}