{"record":{"id":"e9a99be9d0c5279c","repo":"jackwener/OpenCLI","slug":"exception-e9a99b","errorCode":null,"errorMessage":"exception","messagePattern":"exception","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linux-do/auth.js","lineNumber":37,"sourceCode":"      const r = await fetch('/u/' + encodeURIComponent(u) + '.json', {\n        credentials: 'include',\n        headers: { Accept: 'application/json' },\n      });\n      if (r.status === 401 || r.status === 403) {\n        return { kind: 'auth', detail: 'Linux.do /u/<self>.json HTTP ' + r.status };\n      }\n      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      const user = d?.user;\n      if (!user || !user.id) return { kind: 'auth', detail: 'Linux.do /u/<self>.json missing user.id' };\n      return { ok: true, user_id: String(user.id), username: String(user.username || u), name: String(user.name || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('linux.do', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Linux.do /u/<self>.json`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Linux.do whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Linux.do probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, username: probe.username, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'linux-do',\n  domain: 'linux.do',\n  loginUrl: 'https://linux.do/login',\n  columns: ['user_id', 'username', 'name'],\n  quickCheck: hasLinuxDoSessionCookie,\n  verify: verifyLinuxDoIdentity,\n  poll: async (page) => {\n    if (!await hasLinuxDoSessionCookie(page)) {\n      throw new AuthRequiredError('linux.do', 'Waiting for Linux.do _t cookie');\n    }\n    return verifyLinuxDoIdentity(page);\n  },\n});","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linux-do/auth.js#L19-L55","documentation":"Any exception thrown inside the in-page whoami IIFE is caught and returned as {kind:'exception', detail}, which verifyLinuxDoIdentity rethrows as CommandExecutionError `Linux.do whoami failed: <detail>`. This wraps browser-side failures of the probe itself — network errors on fetch, JSON parse errors, DOM access problems.","triggerScenarios":"fetch('/u/<self>.json') rejecting (network failure, CORS/blocked), response.json() throwing on an HTML error body, navigation interrupted mid-probe, or page.evaluate context destroyed.","commonSituations":"Linux.do serving an HTML error page instead of JSON (so r.json() throws); browser navigated away during the probe; offline/proxy network issues; extension or CSP blocking the in-page fetch.","solutions":["Read the detail suffix in the message to identify the underlying browser-side exception","Ensure the browser stays on https://linux.do/ for the duration of verification and retry","Verify network/proxy connectivity to linux.do from the automation browser","If an HTML error page is being returned (json() throws), retry after the server recovers or re-login"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Stay on linux.do and online before probing\nconst onSite = page.url().startsWith('https://linux.do');\nif (!onSite || !navigator.onLine) throw new Error('Browser not ready for linux.do whoami');","typeGuard":null,"tryCatchPattern":"try {\n  const identity = await verifyLinuxDoIdentity(page);\n} catch (e) {\n  if (String(e.message).startsWith('Linux.do whoami failed')) {\n    await page.goto('https://linux.do/'); await page.wait(3);\n    return verifyLinuxDoIdentity(page); // retry once after re-navigation\n  } else throw e;\n}","preventionTips":["Don't navigate the page away while verification is running","Ensure stable network/proxy connectivity to linux.do","Re-navigate to linux.do before retrying after any probe failure","Disable extensions/CSP conflicts that can block in-page fetches"],"tags":["linux-do","whoami","browser-automation","discourse"],"backgroundTag":"in-page-script-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}