{"record":{"id":"4d696ba3675d4816","repo":"jackwener/OpenCLI","slug":"auth-refresh-quickcheck-failed-for-cmd-site","errorCode":null,"errorMessage":"Auth refresh quickCheck failed for ${cmd.site}","messagePattern":"Auth refresh quickCheck failed for (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"src/commands/auth.ts","lineNumber":229,"sourceCode":"    error: code ? `${code}: ${message}` : message,\n  };\n}\n\nfunction refreshCommand(cmd: CliCommand, timeoutSeconds: number): BrowserCliCommand | null {\n  if (cmd.browser !== true) return null;\n  let refreshFunc = cmd.authStatus?.refresh;\n  if (typeof refreshFunc !== 'function') {\n    const quickCheck = cmd.authStatus?.quickCheck;\n    if (typeof quickCheck !== 'function' || !cmd.domain) return null;\n    const refreshUrl = cmd.domain.startsWith('http://') || cmd.domain.startsWith('https://')\n      ? cmd.domain\n      : `https://${cmd.domain}`;\n    refreshFunc = async (page, kwargs, debug) => {\n      await page.goto(refreshUrl);\n      await page.wait(1);\n      const loggedIn = normalizeQuickResult(await quickCheck(page, kwargs, debug));\n      if (loggedIn !== true) {\n        throw new AuthRequiredError(cmd.domain ?? cmd.site, `Auth refresh quickCheck failed for ${cmd.site}`);\n      }\n      return { status: 'touched' };\n    };\n  }\n  return withTimeoutArg({\n    ...cmd,\n    func: refreshFunc,\n    navigateBefore: false,\n    siteSession: 'persistent',\n    defaultWindowMode: 'background',\n  }, timeoutSeconds) as BrowserCliCommand;\n}\n\nfunction normalizeRefreshStatus(result: unknown): 'refreshed' | 'touched' {\n  if (result && typeof result === 'object' && !Array.isArray(result)) {\n    const row = result as Record<string, unknown>;\n    if (row.status === 'refreshed' || row.refreshed === true) return 'refreshed';\n  }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/commands/auth.ts#L211-L247","documentation":"The auth refresh command re-validates a site's login state by navigating to the refresh URL and running quickCheck. If the quick check does not conclusively report logged-in, it throws AuthRequiredError, meaning the stored session/profile for that site cannot be refreshed and the user must re-authenticate interactively.","triggerScenarios":"Running `opencli auth refresh --site <site>` when the stored cookies/session for that site have expired or been invalidated; the site redirects to a login page during quickCheck; the domain override points at an environment where the profile is not logged in.","commonSituations":"Long-lived CI machines whose saved auth profiles expired; site-side session revocation (password change, SSO policy); refreshing against a wrong --domain (e.g. staging) that the profile isn't logged into.","solutions":["Re-authenticate interactively for that site (opencli auth login / whoami flow) to refresh stored credentials.","Verify the --domain/--site points at the environment the profile is actually logged into.","Check the target site is reachable and not redirecting to an SSO/login wall; retry after network issues.","Delete the stale profile for the site and log in again from scratch."],"exampleFix":"// before\nopencli auth refresh --site acme\n// AuthRequiredError: Auth refresh quickCheck failed for acme\n// after\nopencli auth login --site acme   # re-establish session\nopencli auth refresh --site acme","handlingStrategy":"try-catch","validationCode":"const status = await opencli.authWhoami({ sites: [site] });\nif (status !== 'logged-in') {\n  console.warn(`Session for ${site} is '${status}'; run auth login before refresh.`);\n}","typeGuard":"function isRefreshable(status: string): boolean {\n  return status === 'logged-in';\n}","tryCatchPattern":"try {\n  await opencli.authRefresh({ site });\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    console.error(`Session for ${site} expired; re-run: opencli auth login --site ${site}`);\n  } else throw e;\n}","preventionTips":["Check auth status for a site before attempting refresh.","Refresh sessions periodically before they expire rather than after.","Point --domain at the environment the profile was created against.","In CI, fall back to an interactive/service login step when refresh fails."],"tags":["auth","session-expired","quickcheck"],"backgroundTag":"auth-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}