jackwener/OpenCLI · error · CommandExecutionError

Dianping member page rendered but no user_id link found — st

Error message

Dianping member page rendered but no user_id link found — stale dper or layout drift

What it means

CommandExecutionError raised when the Dianping member page renders but the DOM scrape finds no /member/<digits> profile link, so no user_id can be extracted. The library assumes either the dper session is stale (page rendered a logged-out shell) or Dianping's page layout changed. It is a scraping-contract failure, not an auth error per se.

Source

Thrown at clis/dianping/auth.js:31

  await page.goto('https://www.dianping.com/member/myinformation');
  await page.wait(2);
  const finalUrl = await page.evaluate(`location.href`);
  if (/account\.dianping\.com\/(pc)?login/.test(String(finalUrl || ''))) {
    throw new AuthRequiredError('dianping.com', `Dianping member page redirected to login: ${finalUrl}`);
  }
  const info = await page.evaluate(`
    (() => {
      const nicknameEl = document.querySelector('.user-name, .username, .nickname, .user-info .name');
      const nickname = (nicknameEl?.textContent || '').trim();
      const profileLink = Array.from(document.querySelectorAll('a[href*="/member/"]'))
        .map(a => a.getAttribute('href') || '')
        .find(h => /\\/member\\/\\d+/.test(h));
      const uidMatch = String(profileLink || '').match(/\\/member\\/(\\d+)/);
      return { user_id: uidMatch?.[1] || '', nickname };
    })()
  `);
  if (!info?.user_id) {
    throw new CommandExecutionError('Dianping member page rendered but no user_id link found — stale dper or layout drift');
  }
  return { user_id: String(info.user_id), nickname: String(info.nickname || '') };
}

registerSiteAuthCommands({
  site: 'dianping',
  domain: 'dianping.com',
  loginUrl: 'https://account.dianping.com/pclogin',
  columns: ['user_id', 'nickname'],
  quickCheck: hasDianpingSessionCookie,
  verify: verifyDianpingIdentity,
  poll: async (page) => {
    if (!await hasDianpingSessionCookie(page)) {
      throw new AuthRequiredError('dianping.com', 'Waiting for Dianping dper cookie');
    }
    return verifyDianpingIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-login to refresh the dper session, then retry — a stale session often renders a logged-out page without the profile link.
  2. Increase the wait before evaluate (wait for the .user-name/.member link selector instead of a fixed 2s) and retry.
  3. Inspect the live page HTML and update the selectors in auth.js (nickname/user_id extraction) if Dianping changed its layout.
  4. Save the page HTML/screenshot on failure to distinguish layout drift from a bot/verification page.

Example fix

// before
await page.wait(2);
const info = await page.evaluate(...);
// after
await page.waitForSelector('a[href*="/member/"]', { timeout: 10000 }).catch(() => null);
const info = await page.evaluate(...);
Defensive patterns

Strategy: retry

Validate before calling

await page.waitForSelector('a[href*="/member/"]', { timeout: 10000 }).catch(() => null);
// only then call verify

Type guard

function extractUserId(html) { const m = String(html||'').match(/\/member\/(\d+)/); return m ? m[1] : null; }

Try / catch

try { identity = await cli.dianping.verify(); }
catch (e) { if (e.name === 'CommandExecutionError' && /user_id link found/.test(e.message)) { await page.reload({ waitUntil: 'networkidle' }); identity = await cli.dianping.verify(); } else throw e; }

Prevention

When it happens

Trigger: verifyDianpingIdentity loads /member/myinformation, passes the login-redirect check, but page.evaluate returns {user_id: ''} because no anchor matching a[href*='/member/'] with /member/\d+ exists in the DOM.

Common situations: Dianping redesigned the member page selectors; page still loading when evaluate runs (fixed 2s wait too short); logged-out or bot-challenge variant of the page rendered; regional/AB-tested layout without the profile link.

Related errors


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