jackwener/OpenCLI · error · CommandExecutionError
Zhihu search request failed${status ? ` (HTTP ${status})` :
Error message
Zhihu search request failed${status ? ` (HTTP ${status})` : ''} What it means
requireSearchPayload throws this CommandExecutionError when the Zhihu search response carries __httpError with a status other than 401/403 (e.g. 429, 500). The message includes the HTTP status code when known; the remedy hints at retrying later or using -v for detail. It means Zhihu's server rejected the search request at the HTTP level.
Source
Thrown at clis/zhihu/search.js:85
return type;
}
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;View on GitHub (pinned to 49907e53dc)
Solutions
- Wait and retry with backoff — 429/5xx are usually temporary
- Rerun with -v to capture the exact HTTP status and diagnose
- Reduce search frequency and lower --limit to stay under risk-control thresholds
- If status is 404 consistently, update the CLI — the Zhihu search endpoint likely changed
- Log in via the connected Chrome profile to raise rate limits
Example fix
// before: immediate retry
await searchZhihu(q);
// after
catch (err) {
if (err instanceof CommandExecutionError && /HTTP 429/.test(err.message)) {
await sleep(30_000);
return searchZhihu(q);
}
throw err;
} Defensive patterns
Strategy: retry
Validate before calling
// throttle before calling const MIN_INTERVAL_MS = 2000; await sleep(Math.max(0, lastCallAt + MIN_INTERVAL_MS - Date.now()));
Type guard
function isHttpFailure(err) {
return err instanceof CommandExecutionError && /Zhihu search request failed/.test(err.message);
} Try / catch
try {
return await searchZhihu(q);
} catch (err) {
if (isHttpFailure(err) && /HTTP 429|HTTP 5/.test(err.message)) {
await sleep(30_000);
return searchZhihu(q); // bounded exponential backoff in production
}
throw err;
} Prevention
- Rate-limit searches (e.g. one every few seconds) to avoid 429s
- Keep --limit modest (≤20) to reduce server strain
- Add exponential backoff with a retry cap around search calls
- Monitor for persistent 404s which indicate an endpoint/API change needing a CLI update
When it happens
Trigger: The in-page fetch of Zhihu's search endpoint returned any non-2xx status other than 401/403 — e.g. 429 (rate limited), 5xx (server error), 404 (endpoint changed) — stored as payload.__httpError.
Common situations: Hammering the search endpoint with rapid repeated queries (429); Zhihu server-side incident (5xx); Zhihu changing its search API path (404); transient network proxies returning error statuses.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Flomo API returned HTTP ${resp.status}
- ${label} failed: HTTP ${response.status}
- Sales Navigator lead search API returned an unexpected respo
- lobsters domain returned HTTP ${resp.status}
- HTTP ${probe.httpStatus} from nowcoder profile API
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a0d7e2e30ab7a9cf.
Report an issue: GitHub.