jackwener/OpenCLI · error · CommandExecutionError

Taobao my_itaobao rendered but no user_id extractable — stal

Error message

Taobao my_itaobao rendered but no user_id extractable — stale cookie2 or layout drift

What it means

After tracknick confirms a session, verifyTaobaoIdentity scrapes user_id from the rendered my_itaobao page DOM. If the page rendered but no user_id could be extracted, the library throws CommandExecutionError, indicating the stored auth cookie (cookie2) is stale or the page layout changed so the userId regex no longer matches.

Source

Thrown at clis/taobao/auth.js:40

    throw new AuthRequiredError('taobao.com', 'Taobao tracknick cookie absent after navigation');
  }
  const domInfo = await page.evaluate(`
    (() => {
      const nick = (document.querySelector('.user-nick, .site-nav-user, .user-name')?.innerText || '').trim();
      const html = document.body?.innerHTML || '';
      const userIdMatch = html.match(/userId[\"'\\s:=]+(\\d+)/i);
      return { nickname: nick, user_id: userIdMatch?.[1] || '' };
    })()
  `);
  let decodedTracknick = '';
  try {
    decodedTracknick = JSON.parse('"' + tracknick.replace(/\\/g, '\\\\') + '"');
  } catch {
    decodedTracknick = tracknick;
  }
  const nickname = domInfo.nickname || decodedTracknick;
  if (!domInfo.user_id) {
    throw new CommandExecutionError('Taobao my_itaobao rendered but no user_id extractable — stale cookie2 or layout drift');
  }
  return { user_id: String(domInfo.user_id), nickname: String(nickname) };
}

registerSiteAuthCommands({
  site: 'taobao',
  domain: 'taobao.com',
  loginUrl: 'https://login.taobao.com/member/login.jhtml',
  columns: ['user_id', 'nickname'],
  quickCheck: hasTaobaoSessionCookie,
  verify: verifyTaobaoIdentity,
  poll: async (page) => {
    if (!await hasTaobaoSessionCookie(page)) {
      throw new AuthRequiredError('taobao.com', 'Waiting for Taobao tracknick cookie');
    }
    return verifyTaobaoIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-login to refresh cookie2 and other session cookies, then verify again
  2. Inspect the rendered my_itaobao HTML and update the userId extraction regex/selectors in clis/taobao/auth.js to match current markup
  3. Dump page.content() on failure to diagnose whether the page is a captcha/interstitial rather than the real profile page
  4. Pin/retry against the m. or alternate Taobao profile URL if the desktop template drifted

Example fix

// before
const userIdMatch = html.match(/userId["'\s:=]+(\d+)/i);
// after (broaden extraction)
const userIdMatch = html.match(/userId["'\s:=]+(\d+)/i)
  || html.match(/"userId":"?(\d+)/i)
  || (await page.evaluate(() => document.querySelector('[data-userid]')?.dataset.userid));
Defensive patterns

Strategy: try-catch

Validate before calling

const html = await page.evaluate(() => document.body?.innerHTML || '');
if (!/userId["'\s:=]+(\d+)/i.test(html)) console.warn('userId marker missing — layout may have drifted');

Type guard

function hasExtractableUserId(domInfo) {
  return domInfo != null && Boolean(domInfo.user_id) && /^\d+$/.test(String(domInfo.user_id));
}

Try / catch

try {
  const identity = await verifyTaobaoIdentity(page);
} catch (e) {
  if (/no user_id extractable/.test(e.message)) {
    await page.reload({ waitUntil: 'networkidle' }); // or re-login to refresh cookie2
    return verifyTaobaoIdentity(page);
  }
  throw e;
}

Prevention

When it happens

Trigger: domInfo.user_id is falsy after page.evaluate on the my_itaobao page: the userId regex /userId["'\s:=]+(\d+)/i finds no match in body HTML and no .user-nick/.site-nav-user/.user-name selector yields an id. Happens with a half-valid session (cookie2 stale) or Taobao markup changes.

Common situations: Taobao front-end redeploy changed element classes; session valid enough to render page but server treats it as degraded; A/B-tested layout variants; region-specific pages rendering a different template.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/dd0c09b8fb7748d9. Report an issue: GitHub.