{"record":{"id":"39da8ff9eccec3fe","repo":"jackwener/OpenCLI","slug":"auth-39da8f","errorCode":null,"errorMessage":"auth","messagePattern":"auth","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linux-do/auth.js","lineNumber":35,"sourceCode":"      const u = document.querySelector('meta[name=\"current-user-username\"]')?.getAttribute('content') || '';\n      if (!u) return { kind: 'auth', detail: 'Linux.do meta[current-user-username] missing — anonymous' };\n      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);","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linux-do/auth.js#L17-L53","documentation":"The in-page whoami probe returns {kind:'auth'} in three cases: the meta[current-user-username] tag is missing, /u/<self>.json returns HTTP 401/403, or the JSON payload lacks user.id. Each is converted to AuthRequiredError for linux.do — the session cookie exists but the server considers the user unauthenticated for API access.","triggerScenarios":"'_t' cookie present but invalid/expired server-side; linux.do returning 401/403 on the /u/<username>.json endpoint; page not fully loaded so meta tag absent after the 2s wait; suspended/limited account lacking user.id in the API response.","commonSituations":"Cookie expired while the client still holds it (quickCheck passes, verify fails); linux.do behind maintenance or Cloudflare challenge; rate-limited Discourse API; user suspended or logged out remotely.","solutions":["Re-login at https://linux.do/login to refresh the session, then retry verification","Wait and retry if linux.do is rate-limiting or under a Cloudflare challenge","Increase the post-navigation delay/retry so the page's meta tags are present before probing","Check the account status on linux.do for suspension or forced logout"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Cookie may exist but be invalid server-side; treat verify failures as 're-login'\nconst cookies = await page.getCookies({ url: 'https://linux.do' });\nif (!cookies.some(c => c.name === '_t' && c.value)) await linuxDoLogin();","typeGuard":"const probeSaysAuth = (probe) => probe && probe.kind === 'auth';","tryCatchPattern":"try {\n  const identity = await verifyLinuxDoIdentity(page);\n} catch (e) {\n  if (e.name === 'AuthRequiredError') { await linuxDoLogin(); return verifyLinuxDoIdentity(page); }\n  throw e;\n}","preventionTips":["Re-login when the '_t' cookie ages past Discourse's rotation window","Allow the page extra settle time so meta[current-user-username] is present","Watch for Cloudflare challenges on linux.do and resolve them in-browser","Check account status if user.id is persistently missing"],"tags":["linux-do","authentication","discourse","whoami"],"backgroundTag":"auth-session-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}