{"record":{"id":"abad167bc177bb6e","repo":"jackwener/OpenCLI","slug":"zhihu-search-request-failed","errorCode":null,"errorMessage":"Zhihu search request failed","messagePattern":"Zhihu search request failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/search.js","lineNumber":88,"sourceCode":"function unwrapEvaluateResult(payload) {\n    if (payload && typeof payload === 'object' && 'data' in payload && 'session' in payload) return payload.data;\n    return payload;\n}\n\nfunction requireSearchPayload(data, url) {\n    const payload = unwrapEvaluateResult(data);\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError('Zhihu search returned malformed payload');\n    }\n    if (payload.__httpError) {\n        const status = payload.__httpError;\n        if (status === 401 || status === 403) {\n            throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch search results from Zhihu');\n        }\n        throw new CommandExecutionError(`Zhihu search request failed${status ? ` (HTTP ${status})` : ''}`, 'Try again later or rerun with -v for more detail');\n    }\n    if (payload.__fetchError) {\n        throw new CommandExecutionError('Zhihu search request failed', String(payload.__fetchError));\n    }\n    if (!Array.isArray(payload.data)) {\n        throw new CommandExecutionError('Zhihu search returned malformed data list', `URL: ${url}`);\n    }\n    if (!payload.paging || typeof payload.paging !== 'object') {\n        throw new CommandExecutionError('Zhihu search returned malformed paging data', `URL: ${url}`);\n    }\n    return payload;\n}\n\nfunction normalizeResultItem(item) {\n    if (!item || typeof item !== 'object' || item.type !== 'search_result' || !item.object || typeof item.object !== 'object') {\n        return null;\n    }\n    const obj = item.object;\n    if (obj.type !== 'answer' && obj.type !== 'article' && obj.type !== 'question') return null;\n    const key = itemKey(item);\n    const url = itemUrl(obj);","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/search.js#L70-L106","documentation":"requireSearchPayload throws this CommandExecutionError when payload.__fetchError is set — the in-page fetch itself failed (network error, DNS failure, CORS/connection refused) before any HTTP status was received. The raw fetch error string is attached as the remedy/detail.","triggerScenarios":"The Browser Bridge page's fetch() to Zhihu's search endpoint threw (no response at all): connection refused, DNS resolution failure, TLS error, request blocked by the browser before a status was returned — stored as payload.__fetchError.","commonSituations":"No internet / VPN or proxy down; DNS misconfiguration; corporate firewall blocking www.zhihu.com; browser offline mode; Zhihu endpoint unreachable during an outage.","solutions":["Inspect the attached __fetchError detail string for the underlying cause (it is passed as the CommandExecutionError hint)","Verify general connectivity: open www.zhihu.com in the connected Chrome browser manually","Check VPN/proxy/DNS settings if the site is unreachable","Retry after confirming the network path is healthy; check Zhihu status during suspected outages"],"exampleFix":"// before: ignoring detail\n// after: surface the fetch detail\ncatch (err) {\n  if (err instanceof CommandExecutionError && err.hint) console.error('Fetch detail:', err.hint);\n  throw err;\n}","handlingStrategy":"fallback","validationCode":"// pre-flight connectivity check\nconst reachable = await fetch('https://www.zhihu.com/robots.txt', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!reachable) throw new Error('www.zhihu.com unreachable; check network/VPN/DNS');","typeGuard":"function isFetchFailure(err) {\n  return err instanceof CommandExecutionError && err.message === 'Zhihu search request failed' && !/HTTP/.test(err.message);\n}","tryCatchPattern":"try {\n  return await searchZhihu(q);\n} catch (err) {\n  if (isFetchFailure(err)) {\n    console.error('Network-level fetch failure:', err.hint);\n    console.error('Check connectivity/VPN/DNS, then retry.');\n    return null;\n  }\n  throw err;\n}","preventionTips":["Confirm the connected Chrome can load www.zhihu.com before batch runs","Exclude www.zhihu.com from VPN split-tunnel or firewall rules that block it","Use stable DNS (e.g. 1.1.1.1/8.8.8.8) if resolution is flaky","Read the __fetchError hint attached to the error for the exact socket/TLS cause"],"tags":["zhihu","network","fetch-failed","connectivity"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}