{"record":{"id":"50e8cdddb7b2139f","repo":"jackwener/OpenCLI","slug":"jianyu-whoami-failed-probe-detail","errorCode":null,"errorMessage":"Jianyu whoami failed: ${probe.detail}","messagePattern":"Jianyu whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jianyu/auth.js","lineNumber":44,"sourceCode":"      if (userScript) {\n        try {\n          const u = JSON.parse(userScript);\n          userId = userId || String(u.id || u.userId || '');\n          name = String(u.name || u.realName || u.nickName || '');\n        } catch {}\n      }\n      const cookieUid = (document.cookie.split('; ').find(c => c.startsWith('userid_secure=')) || '').split('=')[1] || '';\n      userId = userId || cookieUid;\n      if (!userId && !name) {\n        return { kind: 'auth', detail: 'Jianyu protected page 200 but no user identity surface' };\n      }\n      return { ok: true, user_id: userId, name };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('jianyu360.cn', probe.detail);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Jianyu whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jianyu probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'jianyu',\n  domain: 'jianyu360.cn',\n  loginUrl: 'https://www.jianyu360.cn/',\n  columns: ['user_id', 'name'],\n  quickCheck: hasJianyuUserCookie,\n  verify: verifyJianyuIdentity,\n  poll: async (page) => {\n    if (!await hasJianyuUserCookie(page)) {\n      throw new AuthRequiredError('jianyu360.cn', 'Waiting for Jianyu userid_secure cookie');\n    }\n    return verifyJianyuIdentity(page);\n  },\n});","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jianyu/auth.js#L26-L62","documentation":"CommandExecutionError thrown by verifyJianyuIdentity when the in-page probe function itself threw an exception (the probe catches its own errors and returns { kind: 'exception', detail }). This means the identity check could not even complete — the probe wraps the fetch to the sess endpoint and JSON parsing of window.__USER__ in try/catch, and any failure (network error inside page, fetch rejection, CSP block) surfaces here.","triggerScenarios":"The page.evaluate probe's internal fetch to /swordfish/frontPage/customer/sess/index with credentials: 'include' rejects (network failure, redirect, CORS/CSP), or another runtime error occurs inside the probe's try block; detail contains the exception message.","commonSituations":"Jianyu site temporarily down or returning 5xx; proxy/VPN blocking the in-page request; browser page navigated away mid-probe; site removed or moved the sess endpoint; page context destroyed by a redirect during page.goto.","solutions":["Read probe.detail in the message to identify the underlying exception and fix that cause (DNS, proxy, 5xx)","Retry after confirming https://www.jianyu360.cn/ loads in the automated browser","Disable or relax proxy/VPN/ad-blockers that may block the in-page fetch","Verify the sess endpoint still exists; if the site changed it, update the fetch URL in verifyJianyuIdentity","Wrap verification in retry with backoff for transient network errors"],"exampleFix":"// before\nconst probe = await page.evaluate(...); // detail: 'Failed to fetch'\n// after (retry transient failures)\nfor (let i = 0; i < 3; i++) {\n  try { return await verifyJianyuIdentity(page); }\n  catch (e) { if (!/Failed to fetch/.test(e.message) || i === 2) throw e; await page.wait(2); }\n}","handlingStrategy":"retry","validationCode":"await page.goto('https://www.jianyu360.cn/');\nawait page.wait(2); // ensure page is stable and on-domain before probing\nif (!page.url().includes('jianyu360.cn')) throw new Error('Page navigated away; probe would fail');","typeGuard":"function isProbeException(probe) {\n  return probe != null && typeof probe === 'object' && probe.kind === 'exception' && typeof probe.detail === 'string';\n}","tryCatchPattern":"try {\n  const identity = await verifyJianyuIdentity(page);\n} catch (e) {\n  if (/Jianyu whoami failed: (Failed to fetch|NetworkError)/.test(e.message)) {\n    await page.wait(3); // retry transient network failures\n    return verifyJianyuIdentity(page);\n  }\n  throw e;\n}","preventionTips":["Ensure stable network and no proxy/VPN interference with in-page fetches","Keep the page parked on www.jianyu360.cn during verification (no concurrent navigation)","Retry transient 'Failed to fetch' details with backoff","Monitor the sess endpoint URL for site changes"],"tags":["network","fetch-failed","probe","jianyu"],"backgroundTag":"request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}