{"record":{"id":"f595003ec14d009a","repo":"jackwener/OpenCLI","slug":"unexpected-douban-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Douban probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Douban probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/douban/auth.js","lineNumber":46,"sourceCode":"      const parseUid = (value) => String(value || '').match(/(?:^|\\\\/)people\\\\/(\\\\d+)\\\\/?/)?.[1] || '';\n      const currentUrl = new URL(window.location.href);\n      if (currentUrl.hostname === 'accounts.douban.com' || currentUrl.pathname.startsWith('/passport/')) {\n        return { kind: 'auth', detail: 'Douban /mine redirected to the login flow' };\n      }\n      const navUser = document.querySelector('.nav-user-account .bn-more, .top-nav-info a.bn-more');\n      const navHref = navUser?.getAttribute('href') || navUser?.href || '';\n      const user_id = parseUid(window.location.href) || parseUid(navHref);\n      const name = (navUser?.textContent || document.querySelector('.info h1, h1')?.textContent || '').trim();\n      return user_id\n        ? { ok: true, user_id, name }\n        : { kind: 'unknown', detail: 'Douban user_id parse failed: href=' + navHref + ' location=' + window.location.href };\n    })()\n  `);\n  if (probe?.kind === 'unknown' && cookieUid) {\n    return { user_id: cookieUid, name: '' };\n  }\n  if (probe?.kind === 'auth') throw new AuthRequiredError('douban.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Douban probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'douban',\n  domain: 'douban.com',\n  loginUrl: 'https://accounts.douban.com/passport/login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasDoubanSessionCookie,\n  verify: verifyDoubanIdentity,\n  poll: async (page) => {\n    if (!await hasDoubanSessionCookie(page)) {\n      throw new AuthRequiredError('douban.com', 'Waiting for Douban dbcl2 / ck cookies');\n    }\n    return verifyDoubanIdentity(page);\n  },\n});\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douban/auth.js#L28-L64","documentation":"After the /mine/ probe, verifyDoubanIdentity only handles probe.kind 'auth' (AuthRequiredError), 'unknown' with a cookie-derived uid, and a successful probe. Any other unexpected probe shape (no user id, parse failed and no cookie uid, malformed result) is raised as a CommandExecutionError so the caller sees the raw probe JSON instead of a silent wrong identity.","triggerScenarios":"probe.ok is falsy or probe.user_id missing: /mine/ loaded but the page layout/href yielded no user id and no dbcl2 cookie existed to fall back on; probe evaluates to null/undefined.","commonSituations":"Douban DOM changes breaking the in-page parser; page failed to render /mine/ (error page) before evaluation; rare logged-out-but-unusual redirect state not classified as auth.","solutions":["Log in to douban.com in the reused browser so a valid session exists, then rerun","Inspect the probe JSON in the error message to see which field was missing","Update/patch the probe script if douban changed the /mine/ page structure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!cookies.some(c => c.name === 'dbcl2')) console.warn('No dbcl2 fallback cookie; ensure /mine/ renders the user nav');","typeGuard":"function probeIsUsable(probe) { return probe && (probe.ok || (probe.kind === 'unknown' && probe.user_id)); }","tryCatchPattern":"try { return await verifyDoubanIdentity(page); } catch (e) { if (e instanceof CommandExecutionError && /Unexpected Douban probe/.test(e.message)) { console.error('Probe payload:', e.message, '— check douban /mine/ layout changes'); } throw e; }","preventionTips":["Log the probe JSON on failure to detect douban DOM changes early","Keep the probe script updated when douban changes /mine/","Ensure the page finishes loading before evaluate (wait/retry on transient failures)"],"tags":["douban","unexpected-state","dom-parsing","probe"],"backgroundTag":"unexpected-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}