{"record":{"id":"7e969a6ed3344b03","repo":"jackwener/OpenCLI","slug":"waiting-for-ctrip-login-uid-cookie","errorCode":null,"errorMessage":"Waiting for Ctrip login_uid cookie","messagePattern":"Waiting for Ctrip login_uid cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/ctrip/auth.js","lineNumber":46,"sourceCode":"      userName = decodeURIComponent(userNameRaw);\n    } catch {\n      userName = userNameRaw;\n    }\n  }\n  const vipGrade = params.get('VipGrade') || '';\n  return { user_id: loginUid, name: userName, vip_grade: vipGrade };\n}\n\nregisterSiteAuthCommands({\n  site: 'ctrip',\n  domain: 'ctrip.com',\n  loginUrl: 'https://passport.ctrip.com/user/login',\n  columns: ['user_id', 'name', 'vip_grade'],\n  quickCheck: hasCtripLoginUid,\n  verify: verifyCtripIdentity,\n  poll: async (page) => {\n    if (!await hasCtripLoginUid(page)) {\n      throw new AuthRequiredError('ctrip.com', 'Waiting for Ctrip login_uid cookie');\n    }\n    return verifyCtripIdentity(page);\n  },\n});\n","sourceCodeStart":28,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/auth.js#L28-L51","documentation":"The Ctrip login flow polls the browser page until the `login_uid` cookie appears, which indicates the user completed the login. If the cookie is still missing when the poll runs, the CLI throws AuthRequiredError to signal that interactive login has not happened yet. It is thrown by the ctrip auth command's `poll` hook after a failed `hasCtripLoginUid` check.","triggerScenarios":"Running `clis/ctrip auth` (browser-based login) and calling the poll function before the user has actually submitted the Ctrip passport login form; the passport.ctrip.com/user/login page never sets login_uid because credentials were wrong, the QR code expired, or the user simply has not finished logging in.","commonSituations":"Running the auth command headlessly or unattended so nobody completes the login; Ctrip session expired and re-auth is needed; corporate proxy blocking passport.ctrip.com; user closes the browser before the cookie is written.","solutions":["Complete the Ctrip login in the opened browser window (credentials or QR scan) so login_uid gets set, then rerun the auth command","Rerun the auth flow and wait for it to finish rather than aborting early","Check that passport.ctrip.com is reachable from your network (no proxy/firewall block)","Verify cookies are persisted in the browser profile so subsequent runs reuse the login"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// Before relying on auth state, probe for the cookie via the CLI's own helper\nconst hasUid = await hasCtripLoginUid(page);\nif (!hasUid) {\n  console.warn('Ctrip login_uid missing — rerun the interactive auth flow first');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await ctripAuthPoll(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError && /login_uid/.test(e.message)) {\n    // prompt user to complete login, then retry the poll\n    await waitForUserLogin(page);\n    return ctripAuthPoll(page);\n  }\n  throw e;\n}","preventionTips":["Always run the auth command interactively and wait for the success message before other ctrip commands","Use a persistent browser profile so login_uid survives across runs","Never run the login poll headlessly without a human able to complete the login","Re-run auth proactively when other ctrip commands report session problems"],"tags":["auth","ctrip","cookie","login"],"backgroundTag":"auth-required-login-pending","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}