{"record":{"id":"064c75e0268dadd8","repo":"jackwener/OpenCLI","slug":"linux-do","errorCode":null,"errorMessage":"linux.do","messagePattern":"linux\\.do","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linux-do/auth.js","lineNumber":11,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { registerSiteAuthCommands } from '../_shared/site-auth.js';\n\nasync function hasLinuxDoSessionCookie(page) {\n  const cookies = await page.getCookies({ url: 'https://linux.do' });\n  return cookies.some(c => c.name === '_t' && c.value);\n}\n\nasync function verifyLinuxDoIdentity(page) {\n  if (!await hasLinuxDoSessionCookie(page)) {\n    throw new AuthRequiredError('linux.do', 'Linux.do _t cookie missing — anonymous');\n  }\n  await page.goto('https://linux.do/');\n  await page.wait(2);\n  const probe = await page.evaluate(`(async () => {\n    try {\n      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' };","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linux-do/auth.js#L1-L29","documentation":"The linux-do auth verification first checks for the Discourse '_t' session cookie for https://linux.do. If it is absent or empty, verifyLinuxDoIdentity throws AuthRequiredError('linux.do', ...) because identity cannot be verified while anonymous.","triggerScenarios":"Calling the linux-do auth verify/status flow with a browser profile that has never logged into linux.do, or whose '_t' cookie has expired/been cleared.","commonSituations":"Fresh automation browser profile; cookie purge by browser policy or expiry (Discourse '_t' rotates/expires); logging out of linux.do manually; wrong browser profile selected.","solutions":["Log in at https://linux.do/login in the linked browser so the '_t' cookie is set","Re-run the linux-do auth login/verify command after signing in","Check you are using the same browser profile that holds the linux.do session","If the cookie keeps vanishing, review browser privacy settings/cookie auto-clear policies"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const cookies = await page.getCookies({ url: 'https://linux.do' });\nif (!cookies.some(c => c.name === '_t' && c.value)) {\n  throw new Error('linux.do _t cookie missing; run the login flow first');\n}","typeGuard":"const hasLinuxDoSession = (cookies) => Array.isArray(cookies) && cookies.some(c => c.name === '_t' && c.value);","tryCatchPattern":"try {\n  await verifyLinuxDoIdentity(page);\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    await linuxDoLogin(); // opens https://linux.do/login\n    return verifyLinuxDoIdentity(page);\n  } else throw e;\n}","preventionTips":["Log in at https://linux.do/login before running verify","Use a persistent browser profile for the linux.do session","Re-check the quickCheck (_t cookie) before batch operations","Beware browser privacy settings that auto-clear cookies"],"tags":["linux-do","authentication","cookie","discourse"],"backgroundTag":"missing-session-cookie","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}