jackwener/OpenCLI · error · AuthRequiredError
${r.detail}
Error message
${r.detail} What it means
This AuthRequiredError re-wraps the server's auth-envelope detail. verifySlockSession performs GET /auth/me in the page; when the fetch snippet returns an envelope with kind === 'auth', the session is not authenticated on the Slock domain and the error surfaces the server-provided detail (e.g. invalid or expired session cookie).
Source
Thrown at clis/slock/auth-verify.js:10
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { buildFetchSnippet } from './in-page.js';
import { SLOCK_DOMAIN, SLOCK_HOME_URL } from './shared.js';
// site-auth's whoami sets navigateBefore:false, so verify owns navigation.
export async function verifySlockSession(page) {
await page.goto(SLOCK_HOME_URL);
const snippet = buildFetchSnippet({ method: 'GET', path: '/auth/me', serverScoped: false });
const r = await page.evaluate(`(async () => { ${snippet} })()`);
if (r && r.kind === 'auth') throw new AuthRequiredError(SLOCK_DOMAIN, r.detail);
// unknown / null envelope = contract drift; same typed class as dispatchEvaluateResult
if (!r || r.kind !== 'ok') throw new CommandExecutionError(`unexpected /auth/me result: ${JSON.stringify(r)}`);
const me = r.rows ?? {};
return {
id: me.id ?? null,
name: me.name ?? me.displayName ?? me.username ?? null,
email: me.email ?? null,
};
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the login command for the Slock server to establish a fresh session.
- Confirm the browser profile used by the CLI still holds Slock cookies (don't run headless with a fresh context).
- Check the server's detail message for the exact reason (expired vs invalid) and act accordingly.
- If sessions expire quickly, wrap commands with a re-login-on-AuthRequiredError flow.
Example fix
// before
const me = await verifySlockSession(page);
// after
let me;
try { me = await verifySlockSession(page); }
catch (e) {
if (e instanceof AuthRequiredError) { await login(page); me = await verifySlockSession(page); }
else throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
const me = await verifySlockSession(page);
} catch (e) {
if (e instanceof AuthRequiredError) {
await login(page); // establish fresh session
return verifySlockSession(page);
}
throw e;
} Prevention
- Always login before commands that hit the API.
- Use a persistent browser profile so cookies survive runs.
- Wrap long-running automations with re-login-on-AuthRequiredError logic.
- Check session lifetime expectations for your Slock server.
When it happens
Trigger: Running any command that verifies the session when the browser context has no valid Slock session cookie: never logged in, session expired, cookies cleared, or the server rejected the session.
Common situations: First run before `login`, stale browser profile after server-side session revocation, cookie jar wiped by automation, or SSO token expiry overnight.
Related errors
- Ctrip login_uid cookie absent after navigation
- Instagram sessionid cookie missing
- ${result.detail}
- instagram.com
- LinkedIn JSESSIONID cookie not found. Please sign in to Link
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c3aeed8689eb3da1.
Report an issue: GitHub.