{"record":{"id":"ca69ef5a14d01d62","repo":"jackwener/OpenCLI","slug":"zhihu-identity-probe-failed-http-status-unk","errorCode":null,"errorMessage":"Zhihu identity probe failed (HTTP ${status ?? 'unknown'})","messagePattern":"Zhihu identity probe failed \\(HTTP (.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/auth.js","lineNumber":34,"sourceCode":"    (async () => {\n      try {\n        const r = await fetch('https://www.zhihu.com/api/v4/me?include=url_token', { credentials: 'include' });\n        if (!r.ok) return { __httpError: r.status };\n        return await r.json();\n      } catch (e) {\n        return { __exception: String(e && e.message || e) };\n      }\n    })()\n  `);\n  if (data?.__exception) {\n    throw new CommandExecutionError(`Zhihu whoami failed: ${data.__exception}`);\n  }\n  if (!data || data.__httpError) {\n    const status = data?.__httpError;\n    if (status === 401 || status === 403) {\n      throw new AuthRequiredError('www.zhihu.com', `Zhihu /api/v4/me returned HTTP ${status} — anonymous`);\n    }\n    throw new CommandExecutionError(`Zhihu identity probe failed (HTTP ${status ?? 'unknown'})`);\n  }\n  if (!data.url_token) {\n    throw new AuthRequiredError('www.zhihu.com', 'Zhihu /api/v4/me returned no url_token — anonymous session');\n  }\n  return {\n    url_token: String(data.url_token),\n    name: String(data.name ?? ''),\n    uid: String(data.uid ?? data.id ?? ''),\n  };\n}\n\nregisterSiteAuthCommands({\n  site: 'zhihu',\n  domain: 'www.zhihu.com',\n  loginUrl: 'https://www.zhihu.com/signin',\n  columns: ['url_token', 'name', 'uid'],\n  quickCheck: hasZhihuAuthCookie,\n  verify: verifyZhihuIdentity,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/auth.js#L16-L52","documentation":"If /api/v4/me returns an HTTP error status other than 401/403 (or the status is unknown), verifyZhihuIdentity throws CommandExecutionError 'Zhihu identity probe failed (HTTP <status>)'. It means the identity probe could not be completed — the API responded abnormally but not with a definitive 'anonymous' signal.","triggerScenarios":"Zhihu returns 5xx server errors, 429 rate limiting, or another unexpected status from /api/v4/me; __httpError is set but falls outside the 401/403 branches, including null/undefined status.","commonSituations":"Zhihu server-side incidents or maintenance; aggressive scraping triggering 429; geo/network edge returning 5xx; intermittent failures right after page load.","solutions":["Retry after a delay, especially if the status is 429 or 5xx — these are usually transient.","Check Zhihu status/availability in a normal browser to rule out a site-wide incident.","Reduce request frequency if you see 429 (add delays between commands).","Catch CommandExecutionError for non-auth statuses and implement backoff rather than re-login (re-login won't help for 5xx)."],"exampleFix":"// before\nconst me = await verifyZhihuIdentity(page); // probe failed (HTTP 500)\n// after\nasync function verifyWithRetry(page, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await verifyZhihuIdentity(page); }\n    catch (e) {\n      const m = /HTTP (\\d+)/.exec(e.message);\n      if (m && !['401','403'].includes(m[1]) && i < attempts - 1) {\n        await sleep(2000 * (i + 1)); continue;\n      }\n      throw e;\n    }\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isTransientHttpError(e) { const m = /HTTP (\\d+)/.exec(String(e.message)); return !!m && Number(m[1]) >= 500 || Number(m?.[1] ?? 0) === 429; }","tryCatchPattern":"try { const me = await verifyZhihuIdentity(page); } catch (e) { const m = /HTTP (\\d+)/.exec(e.message); if (m && !['401','403'].includes(m[1])) { await sleep(backoff(attempt++)); return verifyZhihuIdentity(page); } throw e; }","preventionTips":["Add exponential backoff for 5xx/429 statuses","Throttle request frequency when batch-processing","Check zhihu.com availability in a normal browser during incidents","Only re-login for 401/403, not for 5xx"],"tags":["zhihu","http-5xx","rate-limit","transient"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}