{"record":{"id":"745d283702666f9c","repo":"jackwener/OpenCLI","slug":"band-band-session-cookie-missing","errorCode":null,"errorMessage":"Band band_session cookie missing","messagePattern":"Band band_session cookie missing","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/band/auth.js","lineNumber":11,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { registerSiteAuthCommands } from '../_shared/site-auth.js';\n\nasync function hasBandSessionCookie(page) {\n  const cookies = await page.getCookies({ url: 'https://www.band.us' });\n  return cookies.some(c => c.name === 'band_session' && c.value);\n}\n\nasync function verifyBandIdentity(page) {\n  if (!await hasBandSessionCookie(page)) {\n    throw new AuthRequiredError('band.us', 'Band band_session cookie missing');\n  }\n  await page.goto('https://www.band.us/feed');\n  await page.wait(2);\n  const probe = await page.evaluate(`\n    (() => {\n      if (/auth\\\\.band\\\\.us\\\\/login/.test(location.href)) {\n        return { kind: 'auth', detail: 'Band /feed redirected to auth login' };\n      }\n      let userId = '';\n      try {\n        const stack = [window.__INITIAL_STATE__, window.__BAND_STORE__].filter(Boolean);\n        const seen = new Set();\n        while (stack.length) {\n          const node = stack.pop();\n          if (!node || typeof node !== 'object' || seen.has(node)) continue;\n          seen.add(node);\n          if (Array.isArray(node)) { stack.push(...node); continue; }\n          const u = node.user || node.me || node.currentUser;","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/band/auth.js#L1-L29","documentation":"verifyBandIdentity() throws AuthRequiredError when the browser session has no non-empty band_session cookie for band.us. The library cannot confirm a logged-in Band identity without this session cookie.","triggerScenarios":"Running a band command before ever logging in via the site auth flow; the stored browser profile was cleared; Band rotated/invalidated the cookie after a server-side logout.","commonSituations":"Fresh environment/container without a persisted browser profile; password changed elsewhere logging sessions out; cookie expiry after long inactivity.","solutions":["Run the band login/auth command to establish a session (get the band_session cookie)","Verify cookies for https://www.band.us exist in the browser profile used by the tool","Re-login if you recently changed your password or Band invalidated sessions"],"exampleFix":"// before\nbandList() // no session\n// after\nawait bandLogin(); // establishes band_session cookie\nawait bandList();","handlingStrategy":"try-catch","validationCode":"const cookies = await page.getCookies({ url: 'https://www.band.us' });\nconst hasSession = cookies.some(c => c.name === 'band_session' && c.value);\nif (!hasSession) await runBandLogin();","typeGuard":"function hasBandSessionCookie(cookies) {\n  return Array.isArray(cookies) && cookies.some(c => c.name === 'band_session' && Boolean(c.value));\n}","tryCatchPattern":"try {\n  await bandCommand(args);\n} catch (err) {\n  if (err instanceof AuthRequiredError || /band_session cookie missing/.test(err.message)) {\n    await runBandLogin();\n    return bandCommand(args); // retry once after login\n  }\n  throw err;\n}","preventionTips":["Run the site auth/login flow before band commands","Persist the browser profile so cookies survive restarts","Proactively check for the band_session cookie at startup"],"tags":["authentication","session","cookie"],"backgroundTag":"auth-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}