jackwener/OpenCLI · error · CommandExecutionError
Zhihu search request failed
Error message
Zhihu search request failed
What it means
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.
Source
Thrown at clis/zhihu/search.js:88
function unwrapEvaluateResult(payload) {
if (payload && typeof payload === 'object' && 'data' in payload && 'session' in payload) return payload.data;
return payload;
}
function requireSearchPayload(data, url) {
const payload = unwrapEvaluateResult(data);
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
throw new CommandExecutionError('Zhihu search returned malformed payload');
}
if (payload.__httpError) {
const status = payload.__httpError;
if (status === 401 || status === 403) {
throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch search results from Zhihu');
}
throw new CommandExecutionError(`Zhihu search request failed${status ? ` (HTTP ${status})` : ''}`, 'Try again later or rerun with -v for more detail');
}
if (payload.__fetchError) {
throw new CommandExecutionError('Zhihu search request failed', String(payload.__fetchError));
}
if (!Array.isArray(payload.data)) {
throw new CommandExecutionError('Zhihu search returned malformed data list', `URL: ${url}`);
}
if (!payload.paging || typeof payload.paging !== 'object') {
throw new CommandExecutionError('Zhihu search returned malformed paging data', `URL: ${url}`);
}
return payload;
}
function normalizeResultItem(item) {
if (!item || typeof item !== 'object' || item.type !== 'search_result' || !item.object || typeof item.object !== 'object') {
return null;
}
const obj = item.object;
if (obj.type !== 'answer' && obj.type !== 'article' && obj.type !== 'question') return null;
const key = itemKey(item);
const url = itemUrl(obj);View on GitHub (pinned to 49907e53dc)
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
Example fix
// before: ignoring detail
// after: surface the fetch detail
catch (err) {
if (err instanceof CommandExecutionError && err.hint) console.error('Fetch detail:', err.hint);
throw err;
} Defensive patterns
Strategy: fallback
Validate before calling
// pre-flight connectivity check
const reachable = await fetch('https://www.zhihu.com/robots.txt', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!reachable) throw new Error('www.zhihu.com unreachable; check network/VPN/DNS'); Type guard
function isFetchFailure(err) {
return err instanceof CommandExecutionError && err.message === 'Zhihu search request failed' && !/HTTP/.test(err.message);
} Try / catch
try {
return await searchZhihu(q);
} catch (err) {
if (isFetchFailure(err)) {
console.error('Network-level fetch failure:', err.hint);
console.error('Check connectivity/VPN/DNS, then retry.');
return null;
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: No internet / VPN or proxy down; DNS misconfiguration; corporate firewall blocking www.zhihu.com; browser offline mode; Zhihu endpoint unreachable during an outage.
Related errors
- ${label} request failed: ${err?.message ?? err}
- Failed to fetch Flomo memos: ${err instanceof Error ? err.me
- ${label} request failed: ${err?.message ?? err}
- TikTok Studio item_list network failure: ${result.networkErr
- autohome ${contextHint} network error: ${err?.message || err
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/abad167bc177bb6e.
Report an issue: GitHub.