{"record":{"id":"47f4e04e4edd9ce1","repo":"odysseus-dev/odysseus","slug":"data-error-47f4e0","errorCode":null,"errorMessage":"data.error","messagePattern":"data\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"static/js/emailInbox.js","lineNumber":424,"sourceCode":"      _total = data.total || 0;\n      if (_listSpinner) { _listSpinner.destroy(); _listSpinner = null; }\n      _renderList();\n      const unreadCount = _emails.filter(e => !e.is_read).length;\n      const dot = document.getElementById('email-unread-dot');\n      if (dot) dot.style.display = unreadCount > 0 ? '' : 'none';\n    };\n    if (!append && !_senderFilter) {\n      try {\n        const cachedRes = await fetch(`${API_BASE}/api/email/list?folder=${encodeURIComponent(_currentFolder)}&limit=50&offset=${_offset}&cached_only=1${_acct()}`);\n        const cachedData = await cachedRes.json();\n        if (!cachedData.error && (cachedData.emails || []).length) {\n          applyListData(cachedData);\n        }\n      } catch (_) {}\n    }\n    const res = await fetch(`${API_BASE}/api/email/list?folder=${encodeURIComponent(_currentFolder)}&limit=50&offset=${_offset}${fromQS}${_acct()}`);\n    const data = await res.json();\n    if (data.error) throw new Error(data.error);\n    applyListData(data);\n  } catch (e) {\n    console.error('Failed to load emails:', e);\n    if (_listSpinner) { _listSpinner.destroy(); _listSpinner = null; }\n    if (!append && list) {\n      const msg = e && e.message ? `Failed to load: ${e.message}` : 'Failed to load';\n      list.innerHTML = `<div class=\"email-loading\">${msg.replace(/&/g, '&amp;').replace(/</g, '&lt;')}${_emailSetupHint()}</div>`;\n    }\n  } finally {\n    _loading = false;\n  }\n}\n\nasync function loadFolders() {\n  try {\n    const accountQS = _acct().replace(/^&/, '');\n    const res = await fetch(`${API_BASE}/api/email/folders${accountQS ? `?${accountQS}` : ''}`);\n    const data = await res.json();","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/static/js/emailInbox.js#L406-L442","documentation":"Thrown after GET /api/email/list when the endpoint answers 200 (or any parseable JSON) with an error field — the server reports a mailbox-level failure such as IMAP connect failure or missing account config inside the body. The catch renders 'Failed to load: <message>' into the inbox list.","triggerScenarios":"Opening a folder whose IMAP connection fails (bad password, expired OAuth token, provider outage), requesting an account_id that is not set up, or folder name the server cannot select — all returned as {error: ...} rather than a non-2xx status. Note the earlier cached_only probe is intentionally swallowed, so only the authoritative call surfaces errors.","commonSituations":"Gmail app-password revoked; OAuth refresh token expired; account removed from settings while the inbox tab stayed open; server-side IMAP timeout during first sync of a huge folder.","solutions":["Read the data.error string — it typically names the account/folder and IMAP reason","Re-validate the email account credentials in settings (re-auth the account)","Confirm the account_id query parameter still matches a configured account","Retry after the provider outage/timeout clears; use Refresh rather than reopening to force the cache-busted call"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isEmailListOk(d) { return d != null && typeof d === 'object' && !d.error && Array.isArray(d.emails); }","tryCatchPattern":"try { const data = await res.json(); if (data.error) throw new Error(data.error); applyListData(data); } catch (e) { list.innerHTML = `<div class=\"email-loading\">Failed to load: ${esc(e.message)}</div>` + setupHint(e); }","preventionTips":["Surface data.error strings verbatim — they name the account/IMAP cause","Keep account credentials fresh; hook 401/error flows to a re-auth prompt","Use the cached_only probe (as done here) so cached views survive upstream failures","Distinguish auth errors from provider outages in the rendered hint"],"tags":["email","imap","fetch","error-in-body","account-config"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}