jackwener/OpenCLI · error · AuthRequiredError
Ctrip login_uid cookie missing — anonymous
Error message
Ctrip login_uid cookie missing — anonymous
What it means
verifyCtripIdentity first checks the browser session's cookies for a login_uid cookie on www.ctrip.com; if absent or empty it throws AuthRequiredError('ctrip.com', 'Ctrip login_uid cookie missing — anonymous'), meaning you are not logged in. The CLI's Ctrip commands use cookie-based auth, so an anonymous session cannot proceed.
Source
Thrown at clis/ctrip/auth.js:12
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
async function hasCtripLoginUid(page) {
const cookies = await page.getCookies({ url: 'https://www.ctrip.com' });
const loginUid = cookies.find(c => c.name === 'login_uid');
return Boolean(loginUid && loginUid.value);
}
async function verifyCtripIdentity(page) {
if (!await hasCtripLoginUid(page)) {
throw new AuthRequiredError('ctrip.com', 'Ctrip login_uid cookie missing — anonymous');
}
await page.goto('https://my.ctrip.com/myinfo/MyInfoIndex.aspx');
await page.wait(2);
const cookies = await page.getCookies({ url: 'https://www.ctrip.com' });
const cookieMap = Object.fromEntries(cookies.map(c => [c.name, c.value]));
const loginUid = cookieMap['login_uid'] || '';
if (!loginUid) {
throw new AuthRequiredError('ctrip.com', 'Ctrip login_uid cookie absent after navigation');
}
const aheadRaw = cookieMap['AHeadUserInfo'] || '';
const params = new URLSearchParams(aheadRaw);
const userNameRaw = params.get('UserName') || '';
let userName = '';
if (userNameRaw) {
try {
userName = decodeURIComponent(userNameRaw);
} catch {
userName = userNameRaw;View on GitHub (pinned to 49907e53dc)
Solutions
- Run the site's login flow (`ctrip login`) and complete Ctrip login at https://passport.ctrip.com/user/login in the CLI-controlled browser.
- Verify the CLI is attached to the browser profile you actually use and that it isn't an incognito/temporary profile.
- Re-check with `ctrip whoami`/verify after logging in; ensure login_uid appears in cookies for www.ctrip.com.
- Avoid clearing cookies between runs; use a persistent profile.
Defensive patterns
Strategy: validation
Validate before calling
// check for a logged-in session before running Ctrip commands
const who = await opencli.ctrip.whoami().catch(() => null);
if (!who) {
await opencli.ctrip.login(); // completes passport.ctrip.com login
} Try / catch
try {
const data = await runCtripCommand();
} catch (err) {
if (err.name === 'AuthRequiredError' && /login_uid cookie missing/i.test(err.message)) {
await opencli.ctrip.login(); // then retry
} else throw err;
} Prevention
- Run `ctrip login` before scripted Ctrip usage and confirm with whoami/verify.
- Use a persistent browser profile; never incognito or ephemeral containers.
- Don't clear cookies between runs.
- Point the CLI at the same browser profile you log in with.
When it happens
Trigger: Running any Ctrip command or `ctrip login`/verify when the connected browser profile has never logged into ctrip.com, cookies were cleared, or the session uses a fresh headless profile with no cookies.
Common situations: Fresh machine/container with an empty browser profile; browser cookie purge or privacy mode; pointing the CLI at the wrong browser profile; session expired and Ctrip dropped the cookie.
Related errors
- Ctrip login_uid cookie absent after navigation
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Dribbble session cookies are missing
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ea1a6c3fef40a42a.
Report an issue: GitHub.